I am building one Parameterized pipeline job in newer version of jenkins.In older version of jenkins i have used getbinding().getVariables() to retrieve all parameters. But newer version it is return null values. How to retrieve parameters(all) in newer version of jenkins?
We will begin by creating a new job. Go to Jenkins Home, select New Item, add a name for your Job, for the project type, select Pipeline project and click on Ok. On the configure job page select the This project is parameterized checkbox in the general tab.
You just have to use params. [NAME] in places where you need to substitute the parameter. Here is an example of a stage that will be executed based on the condition that we get from the choice parameter. The parameter name is ENVIRONMENT , and we access it in the stage as params.
params. Exposes all parameters defined for the Pipeline as a read-only Map, for example: params.
You can access parameters using "params" variable.
params.each {param ->
println "${param.key} -> ${param.value} "
}
For string parameters, call trim()
. Modifying @Jayan's example:
params.each {param ->
println " '${param.key.trim()}' -> '${param.value.trim()}' "
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With