“定期构建"詹金斯的多分支流水线 [英] "Build Periodically" with a Multi-branch Pipeline in Jenkins

查看:127
本文介绍了“定期构建"詹金斯的多分支流水线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Pipeline插件运行Jenkins 2.我已经建立了一个多分支管道项目,其中每个分支(主分支,开发分支等)在根目录中都有一个Jenkinsfile.设置起来很简单.但是,即使代码未更改,如何使每个分支定期运行(而不是分支索引),我还是一头雾水.我需要在我的Jenkins文件中添加什么以启用定期构建?

I'm running Jenkins 2 with the Pipeline plugin. I have setup a Multi-branch Pipeline project where each branch (master, develop, etc.) has a Jenkinsfile in the root. Setting this up was simple. However, I'm at a loss for how to have each branch run periodically (not the branch indexing), even when the code does not change. What do I need to put in my Jenkinsfile to enable periodic builds?

推荐答案

如果使用声明性样式的Jenkinsfile,则使用

If you are using a declarative style Jenkinsfile then you use the triggers directive.

pipeline {
    agent any
    triggers {
        cron('H 4/* 0 0 1-5')
    }
    stages {
        stage('Example') {
            steps {
                echo 'Hello World'
            }
        }
    }
}

这篇关于“定期构建"詹金斯的多分支流水线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆