How to detect in Jenkins Workflow if parameterized build parameter exists or not? -


what best way can detect if parameter in parameterized build exists or not? closest solution found 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 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 not defined"    } } 

is using getbinding() proper api this, or there better way?

you can use try-catch check existence of parameter:

try {     echo test1     echo 'test1 defined' } catch (err) {     echo 'test1 not defined' } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -