Reputation: 3716
Is it possible to have Jenkins pull a prameterized build from SCM (Git)?
I'm currently using "Pipeline script from SCM" where Jenkins retrieves the pipeline script but not the build parameters e.g. "String Parameter", "Choice Parameter", etc.
Upvotes: 3
Views: 4778
Reputation: 151
Yes, you can retrieve parameters from a Parametrized Build in a Pipeline script from SCM Jenkins job.
To access them in the Jenkins file, use env.[PARAMETER_NAME]
.
For example:
echo 'Param value: ' + env.SOME_PARAMETER
Upvotes: 0
Reputation: 2882
Jenkinsfile (Jenkins pipelines) are capable of this. https://jenkins.io/doc/book/pipeline/syntax/#parameters
Be aware that parameters are post processed. So the 1st build will just be "Build" not "Build with parameters". After the 1st build, it will change.
This can be alleviated by using default values and always referencing the params using the full params.PARAM_NAME syntax. Don't just reference it as PARAM_NAME as this will cause Jenkins to search for env.PARAM_NAME by default.
Upvotes: 4