Reputation: 4252
i have a jenkins job which is required to run specific build tasks on some conditions.
I have set up a boolean parameter called 'skipBuild' which is by default false.
I then setup up the conditional parameter using NOT that needs to execute the step ONLY if the boolean parameter was false. But even on making the parameter true the build step is still run.
[Boolean condition] checking [{ENV,var="skipBuild"}] against [^(1|y|yes|t|true|on|run)$] (origin token: {ENV,var="skipBuild"})
Run condition [Not] enabling perform for step [Execute shell]
...... my command here -DskipBuild=true
Here is my job setup
I basically do not want the execute shell job to be run when the boolean parameter is true
Upvotes: 1
Views: 9215
Reputation: 1271
Make sure your "skipBuild" parameter is a boolean param Working well for me with the following setting The batch command is only executed if the Test value is false.
Upvotes: 0
Reputation: 65
Regular expressions are indeed the best option if you want to negate a certain condition, even if it's not a Boolean variable. For example :
You have a build choice parameter (string) called DRUPAL_ENVIRONMENT. There are 8 choices, among 1 equals "all". Suppose you need 2 conditional build steps depending on DRUPAL_ENVIRONMENT equals "all" or not equals "all", this is how to do it : Equals "all" :
Expression = ^all$
Label = ${ENV,var="DRUPAL_ENVIRONMENT"}
Not equals "all" :
Expression = ^((?!all).)*$
Label = ${ENV,var="DRUPAL_ENVIRONMENT"}
Upvotes: 0
Reputation: 113
I'm not aware of such syntax you are using, but I guess that the token should be ${ENV,var="skipBuild"}
or just ${skipBuild}
Upvotes: 1
Reputation: 693
I found boolean conditions quit confusing and switched to regular expressions. They are quit easy to use. Try regular expression match, label would be {ENV.var="skipBuild"} and expression ^false$. This should run the shell job only if your variable is false.
Upvotes: 0