简化的管道将类似于:
1. build
2. unit test
3. deploy to dev
4. integration tests
5. deploy to prod
对于步骤 #5,我设置了 Jenkins 管道输入命令。我们不会在每次提交时都部署到生产环境,因此如果我们中止所有这些工作,它将有一个很大的灰色构建列表。是否可以有一个跳过选项,以便构建仍然可以显示为 green blue?
我刚刚找到了一个更好的解决方案。您可以使用返回值来访问输入的结果。用户必须选中该复选框才能运行可选阶段。否则将跳过该阶段的步骤。如果您跳过整个舞台,该舞台将消失并“清除”舞台视图历史记录。
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"
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)