您当前的位置: 首页 >  彭世瑜 jenkins

Jenkins设置流水线Pipeline定时任务

彭世瑜 发布时间:2019-04-03 17:00:34 ,浏览量:3

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
关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0539s