我有一个脚本化管道,我想将其移植为声明性形式。我曾经有
// Stages used in developement after each single commit
stage('Build') {
}
stage('Unit Tests') {}
// Other stages only for developer
[...]
// Stages used in test only once per day for instance
stage('Deploy') {
if ( testJob() ) {
} else {
Utils.markStageSkippedForConditional(STAGE_NAME)
}
}
[...]
// Other stages for more testing
Run Code Online (Sandbox Code Playgroud)
然后,对于为开发人员运行的作业,只有管道的第一阶段在 Jenkins 中可见。在声明中,我有:
pipeline {
[...]
stages {
stage ('Build') {
[...]
}
stage ('Unit Tests') {
[...]
}
[...]
stage ('Deploy') {
when { expression …Run Code Online (Sandbox Code Playgroud)