13

Is there a way to enable/disable build steps of a build job in Jenkins. A method like a check box to enable/disable the build steps, so we can temporarily skip some steps which should not run. (This is helpful for testing a build job)

I would like to know whether there is a plugin to do this?

LeoN
  • 1,590
  • 1
  • 11
  • 19
  • I have just found the need for this too. An example of why someone may want to do this is when you have a job with long running steps, like NuGet package restore, or the build itself and you are testing downstream steps, it would be nice to skip the earlier "slow" steps. Yes you can delete the steps but then you have to re-add them. To be able to just toggle a step to be enabled\disabled would be a great feature. – Dib Jul 05 '17 at 09:00

1 Answers1

17

You can use the Conditional Build Step Plugin to do this. Surround the build step you want to toggle in a conditional step (single) and set it to run 'Never'. This will skip the build step until you want to enable it again.

If you want it to be a dynamic option you can script the plugin to enable or disable the build step depending on whether particular conditions are met, eg: A parameter has a particular value, a file exists, etc.

IanAWP
  • 509
  • 4
  • 7
  • 1
    a clever method, however; not elegant as a single checkbox -or something else- to disable/Enable. Such a plugin would be awesome I think. – tolgayilmaz May 16 '17 at 12:15
  • 1
    You can also use Run Condition Plugin. It is what Conditional Build Step Plugin is using. – Gerhard Powell Oct 11 '17 at 22:34
  • when you have jobs with many steps it is hard to rewrite it only to surround block by conditional step (especially if there already other conditional steps) and makes it less observable – Sasha Bond Jan 29 '20 at 17:45