在我的Jenkinsfile中,我并行执行2个阶段,这些阶段之一将由其他几个连续阶段组成。当我运行脚本并检查BlueOcean中的管道时,该阶段顺序表示为一个单个节点。
(简化的)脚本如下:
node {
stage('Stage 1') {...}
stage('Stage 2') {...}
stage('Stages 3 & 4 in parallel') {
parallel(
'Stage 3': {
stage('Stage 3') {...}
},
'Stage 4': {
stage('Stage 4a') {...}
stage('Stage 4b') {...}
}
)
}
}
所以在BlueOcean中,此脚本在阶段4中产生一个节点,而我希望看到两个节点,因为它由两个连续的阶段组成。
答案 0 :(得分:5)
我也遇到了脚本管道的相同问题。如果您对声明性管道不满意,可以使用以下方法:
pipeline {
agent any
stages {
stage('Stage 1') { steps {pwd()}}
stage('Stage 2') { steps {pwd()}}
stage('Stages 3 & 4 in parallel') {
parallel {
stage('Stage 3') { steps {pwd()}}
stage('Stage 4') {
stages {
stage('Stage 4a') { steps {pwd()}}
stage('Stage 4b') { steps {pwd()}}
}
}
}
}
}
}
答案 1 :(得分:0)
使用最新版的jenkins 2.235.3和最新的插件,现在可以在脚本化管道中运行。
node ('fetch') {
stage('Stage 1') { sh(script:"echo Stage1",label: "sh echo stage 1")}
stage('Stage 2') { sh(script:"echo Stage2",label: "sh echo stage 2")}
stage('Stages 3 & 4 in parallel') {
parallel(
'Stage 3': {
stage('Stage 3') {sh(script:"echo Stage3",label: "sh echo stage 3")}
},
'Stage 4': {
stage('Stage 4a') {sh(script:"echo Stage4a",label: "sh echo stage 4a")}
stage('Stage 4b') {sh(script:"echo Stage4b",label: "sh echo stage 4b")}
}
)
}
}