简化的管道看起来像:
1. build
2. unit test
3. deploy to dev
4. integration tests
5. deploy to prod
对于第 5 步,我设置了 Jenkins 管道输入命令。我们不会在每次提交时都部署到生产环境,因此如果我们中止所有这些工作,它将有一个很大的灰色构建列表。是否可以有一个跳过选项,以便构建仍然可以显示为绿色蓝色?
最佳答案
我刚刚找到了一个更好的解决方案。您可以使用返回值来访问输入的结果。用户必须选中该复选框才能运行可选阶段。否则该阶段的步骤将被跳过。如果您跳过整个阶段,该阶段将消失并“清除”阶段 View 历史记录。
stage('do optional stuff?') {
userInput = input(
id: 'userInput', message: "Some important question?", parameters: [
booleanParam(defaultValue: false, description: 'really?', name: 'myValue')
])
}
stage('optional: do magic') {
if (userInput) {
echo "do magic"
} else {
// do what ever you want when skipping this build
currentBuild.result = "UNSTABLE"
}
}
关于Jenkins 持续交付管道根据输入跳过阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40896729/