这是一个要重现的示例管道。使用 Jenkins 2.414.1 和 Blue Ocean 1.27.6.
pipeline {
agent any
parameters {
booleanParam(name: 'IS_DEPLOY_LG', defaultValue: true, description: 'Deploy to LG')
booleanParam(name: 'IS_DEPLOY_SM', defaultValue: true, description: 'Deploy to SM')
}
stages {
stage ("Deploy") {
parallel {
stage('SM') {
when { expression { params.IS_DEPLOY_SM } }
steps {
script {
echo 'Running SM'
sleep 15
}
}
}
stage('LG') {
when { expression { params.IS_DEPLOY_LG } }
steps {
script {
echo 'Running LG'
sleep 15
}
}
}
}
}
}
}
当两个布尔参数都为 true(选中)时,并行管道阶段将在管道运行时按预期运行。
如果只有一个参数为 true,Blue Ocean 将在管道持续时间内显示“排队等待运行”。
这似乎可能是一个错误,但不确定,管道代码有什么问题吗?
只有在管道完成后才会显示已完成的阶段。
我本来打算在 Jenkins Jira 上创建一个关于此问题的错误单,但看起来已经有一个 - https://issues.jenkins.io/browse/JENKINS-48879。在评论中,建议的解决方法是添加一个虚拟阶段,这似乎有帮助,例如-
pipeline {
agent any
parameters {
booleanParam(name: 'IS_DEPLOY_LG', defaultValue: true, description: 'Deploy to LG')
booleanParam(name: 'IS_DEPLOY_SM', defaultValue: true, description: 'Deploy to SM')
}
stages {
stage ("Deploy") {
parallel {
stage('SM') {
when { expression { params.IS_DEPLOY_SM } }
steps {
script {
echo 'Running SM'
sleep 15
}
}
}
stage('LG') {
when { expression { params.IS_DEPLOY_LG } }
steps {
script {
echo 'Running LG'
sleep 15
}
}
}
stage('(Workaround)') {
steps {
sleep 10
}
}
}
}
}
}