Issue
I want to temporary disable some stages in Jenkinsfile. Removing them and then restoring from version history seems like too much hasssle. I tried adding this:
stage('Tests') {
when {
false
}
(...)
But results in an error when I trigger the job:
WorkflowScript: 30: Expected a when condition @ line 30, column 7.
when {
^
WorkflowScript: 30: Empty when closure, remove the property or add some content. @ line 30, column 7.
when {
Is there a way to do when: never
in Jenkins declarative pipelines?
Solution
You can evaluate a boolean expression to disable the stage. Furthermore you could simply remove the stage or comment it out.
stage('Tests') {
when {
expression { false }
}
...
Answered By - Michael Kemmerzell
Answer Checked By - Candace Johnson (JavaFixing Volunteer)