In Jenkins, at times we may require Jenkins to execute some build step on one condition and another in case of other condition. For e.g: It may be required to run a particular test/batch command on Weekdays and some other batch condition on weekends. We can create a job to perform different tasks based on the condition satisfied.
To add a conditional build step, follow below steps in Jenkins.
To add a conditional build step, follow below steps in Jenkins.
- Navigate to Jenkins>Manage Jenkins>Manage Plugins and go to available tab.
- Search for Conditional buildstep as shown below and click on install without restart.
- It will install the plugin and will show success once installation completes.
- Now the plugin can be used in the Jenkins job as shown below.In the job, add build step as Conditional step (single)
- Provide the conditional step from the list as shown below and execute the build command.