如何在Jenkins的管道中添加post构建操作

时间:2017-04-05 10:04:42

标签: jenkins jenkins-plugins jenkins-pipeline

以下是我的管道脚本

configfs: version magic '3.14.38-6UL_ga+ge4944a5 SMP preempt mod_unload modversions ARMv7 p2v8 ' should be '3.14.38-6UL_ga+ge4944a5 SMP preempt mod_unload ARMv6 p2v8 '

上面的groovy脚本会按顺序触发多个构建。序列完成后,我有另一个构建要运行。我没有在管道作业配置中看到任何后期构建选项。

我们是否可以添加更多行,如下所示:

node(Slave01) {
currentBuild.displayName = "${URL_Name}"
}
stage 'Pt2ctf process'
node(Slave01) {
build job: 'Pt2ctf_16_7', parameters: [string(name: 'URL_Name', value: "${URL_name}"), string(name: 'Display_Name', value: "${Display_Name}")]
}
stage 'add_fields'
node(Slave01) {
build job: 'add_fields_16_7', parameters: [string(name: 'URL_Name', value: "${URL_Name}")]
}

或者我们还有其他选择吗?请建议

2 个答案:

答案 0 :(得分:6)

如果使用声明性管道,您可以简单地将post操作添加到管道脚本中。 它在Pipeline syntax reference中解释。

答案 1 :(得分:4)

您可以为帖子构建添加一个阶段,以便在管道中添加帖子构建操作:

stage 'post-build'
node(Slave01){
build job: 'testing_build'
}

您可以将此阶段用作:

try {
    //Stages to be included in build
    ...
} catch {
    ...
} finally {
    stage 'post-build'
    ...
}
相关问题