如何在Job-1完成时间10小时后在Jenkins中创建项目以运行Job-2 .Job-2应该从Job-1获取相同的参数输入?
答案 0 :(得分:0)
你可以,使用构建步骤
https://jenkins.io/doc/pipeline/steps/pipeline-build-step/
从工作1开始你的工作2,将相同的参数传递下去。在超时块
中将此步骤嵌套在try / catch的catch中https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-timeout-code-enforce-time-limit
这样,当超时到期时,你会发现它失败,而是开始你的工作。确保不在节点步骤中使用超时步骤,以便不使用执行程序。
这样的事情:
node {
//do job 1 tasks
}
timeout(time: 10, unit: 'HOURS') {
try {
// Do nothing? Maybe have an input step allowing cancellation?
} catch (err) {
// Timeout expires, execute next build
build job: 'Job2', parameters: [[$class: 'StringParameterValue', name: 'param', value: params.PARAM1]]
}
}
可能有更好的方法来实现这一点,但这至少允许你不在执行器上(使用shell等待需要执行程序)