如何在Jenkins declarative pipeline
中运行特定阶段?
示例:
如果我想run only the stage 3(Deploy Nexus artifact) without running the stage 1, 2 and 4.
如何实现?
答案 0 :(得分:0)
您可以在每个要跳过的阶段使用when表达式。变量checkoutCode
,runSonarScan
,deployNexusArtifact
可以静态或动态设置为环境变量。
environment {
checkoutCode = true
runSonarScan = true
deployNexusArtifact = true
}
stage('Gitlab code Checkout') {
when { expression { "${checkoutCode}" == 'true' } }
...
}
stage('Sonarqube scan') {
when { expression { "${runSonarScan}" == 'true' } }
...
}
stage('Deploy Nexus artifact') {
when { expression { "${deployNexusArtifact}" == 'true' } }
...
}