I cheat using try/catch:

try{ echo "MyParam is:"+ myParam} catch(ex) { myParam = "default" }


Its ugly, but works. Obviously you can alter this concept to whatever works 
for you :-)


-M

On Thursday, September 29, 2016 at 1:37:05 AM UTC-7, Sverre Moe wrote:
>
> I can no longer check if a build parameter exist before accessing it
>
> This has worked previously before I updated Jenkins and the Pipeline 
> plugins:
> def myParam = false
> if (getBinding().hasVariable("MY_PARAM")) {
>     myParam = Boolean.parseBoolean(MY_PARAM)
> }
>
>
> final def myParam = MY_PARAM
>
>
> The latter will fail on the very first build on all new branches that are 
> added.
>
>
> This will print out only for the second println.
> if (getBinding().hasVariable("MY_PARAM")) {
>     println "My_PARAM1="+MY_PARAM
> }
> println "MY_PARAM2="+MY_PARAM
> Output: 
> MY_PARAM2=false
>

-- 
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/e81286b7-10f9-47d1-9b88-cb8effc0da5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to