I have a scripted pipeline that I want to port to declarative form. I used to have
// 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
Then for the jobs that run for developers only the 1st stages of the pipeline where visible in Jenkins. In declarative, I have:
pipeline {
[...]
stages {
stage ('Build') {
[...]
}
stage ('Unit Tests') {
[...]
}
[...]
stage ('Deploy') {
when { expression { testJob() }
[...]
}
[...]
}
}
But even for the development job, I see all the stages. Is there a way to get the same behavior as with scripted pipeline?