如何为现有的自由式项目创建管道? [英] How can I create a pipeline for existing freestyle projects?
问题描述
我在詹金斯自由式项目中工作了一段时间.
I am working for some time with jenkins freestyle projects.
现在,我正在寻找一种创建管道"的解决方案,该管道可以执行多个(参数化的)自由式项目.像这样:
Now I was looking for a solution to create a "pipeline" which execute multiple of these (parameterized) freestyle projects. Something like this:
// execute freestyle project A with parameter p1=a
// execute freestyle project B with parameter p2=b
if((A finished successfully) && (B finished successfully)){
// execute project C with parameter p3=c
if((C finished successfully) && p4 == "yes"){
// execute project D with parameter p5=d
}
}
我找到了Jenkins Pipeline,但是我不确定这是否是Jenkins Pipeline的实际用例.在我看来,Jenkins Pipeline看起来更像是一个高级的自由式项目,而不是现有项目的编排"工具.
I found Jenkins Pipeline, but I'm not sure if this is the actual use case for a Jenkins Pipeline. Jenkins Pipeline looks more like an advaned freestyle project to me, not an "orchestrating" tool for existing projects.
那么我应该使用哪个插件呢?
So which plugin should I use for this need?
推荐答案
您绝对可以使用Jenkins管道
You definitely can do it using Jenkins pipeline
stage('triggering jobs') {
build job: 'A', parameters: [string(name: 'p1', value: 'a')]
build job: 'B', parameters: [string(name: 'p2', value: 'b')]
build job: 'C', parameters: [string(name: 'p3', value: 'c')]
if (p4 == 'yes') {
build job: 'D', parameters: [string(name: 'p5', value: 'd')]
}
}
您不需要显式检查下游作业的结果状态,因为如果其中一项失败,则编排作业将失败.
有关更多信息,请参见构建步骤信息.
You don't need to check explicitly result statuses of downstream jobs because the orchestration job will fail if one of them fails.
See build step for more information.
这篇关于如何为现有的自由式项目创建管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!