Reputation: 361
I am building a scripted Jenkins pipeline. the Jenkins file is fetched from a git repository. I want to parameterize the Repository URL. I have created a String parameter. I tried to access the string parameter in 'Repository URL' field, but is not working. I get an error that the parameter is not a recognised URL. However, i am able to access the variable in a shell script.
For example, if the string parameter is defined as "GIT_URL", I am trying to access it using ${GIT_URL} or ${params.GIT_URL} or ${env.GIT_URL} or $GIT_URL. No luck. Any thoughts.
Upvotes: 5
Views: 7901
Reputation: 301
For me, the only way to resolve this issue was to uncheck the Lightweight checkout checkbox in the build config.
Reference: Pipeline script from SCM does not expand build parameters/env variables for lightweight checkouts
Upvotes: 8
Reputation: 37610
It is ${params.GIT_URL}
. Make sure that you run the pipeline twice, as a change in the job's parameters in Jenkinsfile
are stored during the first run and then your value is available during the second run.
Upvotes: 0