Jos*_*cía 5 crontrigger jenkins jenkins-pipeline multibranch-pipeline
我希望在声明性管道 jenkins 作业中为每个分支实现不同的 cron 触发器。目前,我只在我们的 dev 分支上触发每小时构建:
String cron_string = BRANCH_NAME == "dev" ? "@hourly" : ""
pipeline {
triggers {
cron(cron_string)
}
//stages, options and more code here...
}
Run Code Online (Sandbox Code Playgroud)
我的目标是拥有两个单独的 cron 字符串,它们将在不同的时间在不同的分支中触发构建(例如:在 dev 中每小时构建一次,在 master 中每三个小时构建一次),但是执行将是相同的。我的问题是,我可以做类似下面的代码块的事情还是应该采取不同的方法?
String cron_string_1 = BRANCH_NAME == "dev" ? "0 8/20 ? * MON-FRY" : ""
String cron_string_2 = BRANCH_NAME == "master" ? "0 8/20/3 ? * MON-FRY" : ""
pipeline {
triggers {
cron(cron_string)
}
//stages, options and more code here...
}
Run Code Online (Sandbox Code Playgroud)
小智 0
这对我有用(使用脚本化管道):
if (BRANCH_NAME == "dev") {
properties(
[
pipelineTriggers([cron('0 8,13,17 * * *')])
]
)
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
854 次 |
最近记录: |