【问题标题】:How to schedule Jenkins build in pipeline script with custom parameters如何使用自定义参数安排 Jenkins 在管道脚本中构建
【发布时间】:2019-02-19 12:03:30
【问题描述】:

我有一个包含多个参数的 Jenkins 作业,每个参数都有默认值,例如:

SUITE_NAME: business/common.xml     
BROWSER_NAME: ff

我需要 cron 启动 2 次作业,使用不同的输入参数,例如:

第一次发射:凌晨 5 点

SUITE_NAME: business/common.xml
BROWSER_NAME: ff

第二次发射:早上 7 点

SUITE_NAME: events/some-other.xml
BROWSER_NAME: ff

所以SUITE_NAME 和其他一些参数可能会有所不同。 如何通过 Jenkins 界面在作业设置的管道脚本中进行设置?

我现在看到的唯一解决方案是每小时触发一次构建,获取当前时间,然后根据是 5AM 还是 7AM 更改 SUITE_NAME 的值,但这看起来很奇怪。

提前致谢。

【问题讨论】:

  • 为什么不用两个单独的管道(一个是 cron 5AM,另一个是 7AM)用不同的参数触发目标作业?
  • 因为从概念上讲它是相同的参数化构建,我不想克隆其他设置。

标签: jenkins cron jenkins-pipeline


【解决方案1】:

通过使用此答案和插件解决:

add build parameter in jenkins build schedule

https://github.com/jwmach1/parameterized-scheduler

00 05 * * 1-5 %SUITE_NAME=business/common.xml
05 05 * * 1-5 %SUITE_NAME=events/some-other.xml

等等……

【讨论】:

    猜你喜欢
    • 2015-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 2011-10-23
    相关资源
    最近更新 更多