'Disable a stage in Jenkinsfile

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source