12
votes

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?

1
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

1 Answers

16
votes

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.