Jenkins设置流水线Pipeline定时任务

版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/88999830

1、新建流水线任务

在这里插入图片描述

2、构建触发器

* * * * *   # 为每分钟执行
# 分时日月周 与crontab一样

在这里插入图片描述

3、流水线任务

在这里插入图片描述

定义(Pipeline script)

流水线语法 -> 片段生成器

示例步骤(sh: Shell Script)

echo $(date "+%Y-%m-%d %H:%M:%S") hello world >> /root/hello.txt

装换为pipeline脚本

sh label: '', script: 'echo $(date "+%Y-%m-%d %H:%M:%S") hello world >> /root/hello.txt'

在这里插入图片描述

填入流水线框

pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                sh label: '', script: 'echo $(date "+%Y-%m-%d %H:%M:%S") hello world >> /root/hello.txt'
            }
        }
    }
}

保存

查看结果

$ tail -f hello.txt

2019-04-03 16:37:00 hello world
2019-04-03 16:38:00 hello world
2019-04-03 16:39:00 hello world
2019-04-03 16:40:00 hello world

猜你喜欢

转载自blog.csdn.net/mouday/article/details/88999830