Clean way to exit declarative Jenkins pipeline as success?
A solution that worked for me was to create a stage with sub-stages and put the check in the top level stage.
stage('Run if expression ') { when { expression { skipBuild != true } } stages { stage('Hello') { steps { echo "Hello there" } } } }
So I put all the stages that I want to continue inside this stage. And everything else outside of it. In your case you would put all your build stages inside the stage with when check.