Hi,

I tried reading:
http://stackoverflow.com/questions/28572080/jenkins-workflow-how-to-access-parameters-in-a-parameterized-build/
for some ideas, but still am not sure.

I want to have a single workflow groovy file, shared across multiple
Jenkins builds.
If I have a workflow, where "this build is parameterized" is set,
how can I detect in the workflow if a particular build parameter is defined
or not,
without throwing an exception?

The closest solution I found was to do this in groovy:

node {
   groovy.lang.Binding myBinding = getBinding()
   boolean mybool = myBinding.hasVariable("STRING_PARAM1")
   echo mybool.toString()
   if (mybool) {
       echo STRING_PARAM1
       echo getProperty("STRING_PARAM1")
   } else {
       echo "STRING_PARAM1 is not defined"
   }

   mybool = myBinding.hasVariable("DID_NOT_DEFINE_THIS")
   if (mybool) {
       echo DID_NOT_DEFINE_THIS
       echo getProperty("DID_NOT_DEFINE_THIS")
   } else {
       echo "DID_NOT_DEFINE_THIS is not defined"
   }}


Is that the best way to do it, or is there a better way?

--
Craig

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVcKw0Lsw6JdK2WcV1m1PF107qHZaCOzVPoERWqvmVkK9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to