Jenkins 检查并行阶段的状态
我有这样的想法:Jenkins 检查并行阶段的状态,jenkins,jenkins-pipeline,jenkins-declarative-pipeline,Jenkins,Jenkins Pipeline,Jenkins Declarative Pipeline,我有这样的想法: stages { stage('createTemplate') { parallel { stage('template_a') { creating template a } stage('template_b') { creating template b } } }
stages {
stage('createTemplate') {
parallel {
stage('template_a') {
creating template a
}
stage('template_b') {
creating template b
}
}
}
stage('deployVm') {
parallel {
stage('deploy_a') {
deploy vm a
}
stage('deploy_b') {
deploy vm b
}
}
}
}
parallel {
stage('a') {
stages {
stage ('template_a') { ... }
stage ('deploy_a') { ... }
}
stage('b') {
stages {
stage ('template_b') { ... }
stage ('deploy_b') { ... }
}
}
}
如何确保deployVm阶段仅在各个createTemplate阶段成功时运行?您可能希望运行一个并行的
阶段,如下所示:
stages {
stage('createTemplate') {
parallel {
stage('template_a') {
creating template a
}
stage('template_b') {
creating template b
}
}
}
stage('deployVm') {
parallel {
stage('deploy_a') {
deploy vm a
}
stage('deploy_b') {
deploy vm b
}
}
}
}
parallel {
stage('a') {
stages {
stage ('template_a') { ... }
stage ('deploy_a') { ... }
}
stage('b') {
stages {
stage ('template_b') { ... }
stage ('deploy_b') { ... }
}
}
}
这将确保只有deploy
的阶段是成功的template
阶段之后的阶段。如果其中一个createTemplate
并行阶段不成功,您的管道停止运行,并且从一开始就不会进入任何deployVm
阶段。那么如何实现这样一种场景,即即使“a”部分失败,我仍希望继续使用“b”部分?对于这个特定示例,这是可以的,但实际上,我将有更多与a和b相同的后续步骤(将有10多个并行作业),在这种情况下,您如何避免重复相同的代码?请参见例如,有关创建并行步骤的脚本编写。