Published August 01, 2018 by

Build Jenkins Job with Condition and Parameter

If you look forward to Jenkins for most of your development operations then, at some point in time you might have felt the need of something which allows you to condition your steps. Of course, it is not such a good idea to create individual jobs each time you want to run and test specific build step/s. The solution is to use a Conditional BuildStep plugin.

This plugin gives you additional control over your build steps by simply allowing you to add various conditional checks. There are several conditions that you may choose from, and these are all defined.


Suppose we want to start or stop apache service via reading user parameter.

Install Conditional BuildStep plugin.

Configure Job

1. Go to Jenkins Job and tick This project is parameterized.

2. Click on Add Parameter and select Choice Parameter

3. Here give a name of the parameter and also define Choices of a parameter.
    Remember name is act as a Variable name

4. Scroll down to the Build option and Add build step.

    Select Conditional steps(multiple)

5. Select Run? is Strings Match
    Create two Conditional steps as per below

    Condition 1: (for apache START)

   Condition 2: (for apache STOP)

Also, you can create a simple Execute shell script

6. Click Save

7. Now build job with a parameter.

Select your choice and Build.