I have a pipeline script that should work with and without parameters. So I have to check if the parameter is available.
I tried if(getBinding().hasVariable(\"mypa
The problem: Avoiding null parameters or not configured one's in your pipeline job
Solution: You've got 2 options in order to set default configuration to variables in declarative pipelines
Option 1. Using jenkins ability to set parameters scope fallback , this affect your pipeline configuration on job in jenkins (if your configure things in your declarative pipeline it will override your configuration in job parameters).
parameters{
booleanParam(defaultValue: false, description: 'some description', name: 'SOME_FLAG')
}
Option 2. Securing your variables yourself, check if variable is not null and then assign the variable in the pipeline , this functionality doesn't affect your job configuration and it's better in my opinion:
some_flag = params.SOME_FLAG != null ? params.SOME_FLAG.toBoolean() : false