将参数传递给由计划触发的 Jenkinsfile 作业

Fer*_*sta 5 jenkins jenkins-pipeline

我的 jenkinsfile 作业接受 groovy 脚本内使用的一些参数。此类作业由 SCM 轮询和具有多个计划的 cron 触发。我想根据计划的时间为作业参数设置不同的值。是否可以?如果是这样,我该怎么办?

Fer*_*sta 4

我找到了插件Parameterized Scheduler Plugin

它允许您定义许多类似 cron 的格式化条目,但每个定义都有附加参数。

用法示例:

#run against the integration at 15 past the hour
15 * * * * % env=int
#run against the QA at 30 past the hour
30 * * * % env=qa
Run Code Online (Sandbox Code Playgroud)