Conditional Build Steps with Logical (and/or) Operators

1,344 views
Skip to first unread message

David Michener

unread,
Dec 1, 2017, 2:12:00 PM12/1/17
to job-dsl-plugin

I have been able to create a working DSL script that will build a new Job that will run a Conditional Build step with a Boolean logical operator based upon Build Parameter.

parameters {
      booleanParam('COMPILE_CHECK', false, 'Run code compile check.')
    }

 steps { 
    conditionalSteps { 
        condition {
            booleanCondition('${ENV,var="COMPILE_CHECK"}')
        }
        steps{
            batchFile("_build\\BuildCI.bat Release")
                  batchFile("_build\\RunAllUnitTests.bat")
        }
    }
    }

But I haven't been able to get work DSL that would run this Build Step, if one or more parameters are true:

parameters {
      booleanParam('COMPILE_CHECK', false, 'Run code compile check.')
      booleanParam('DEPLOY_CHECK', false, 'Run deploy check.')
    }

   steps { 
    conditionalSteps { 
        condition {
            booleanCondition('${ENV,var="COMPILE_CHECK"}')
*** HOW DO YOU SAY "OR" HERE?
            booleanCondition('${ENV,var="DEPLOY_CHECK"}')
        }
        steps{
            batchFile("_build\\BuildCI.bat Release")
                   batchFile("_build\\RunAllUnitTests.bat")
        }
    }
    }

I can make this type of configuration via the Jenkins GUI, just nothing that works here.  My latest attempts give an error like this:
Processing provided DSL script
ERROR: (script, line 39) No signature of method: javaposse.jobdsl.dsl.helpers.step.RunConditionContext.conditions() is applicable for argument types: (script$_run_closure1$_closure4$_closure10$_closure18$_closure20$_closure21) values: [script$_run_closure1$_closure4$_closure10$_closure18$_closure20$_closure21@915290]
Possible solutions: getCondition()
Finished: FAILURE

TIA!

Victor Martinez

unread,
Dec 1, 2017, 3:39:01 PM12/1/17
to job-dsl-plugin

David Michener

unread,
Dec 4, 2017, 11:05:27 AM12/4/17
to job-dsl-plugin
Thanks Victor, that worked!
Reply all
Reply to author
Forward
0 new messages