-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Jenkins LTS 2.32.3 + All plugins up to date.
Pipeline: Build Step : 2.4
Git client plugin : 2.3
-
-
git plugin 4.14.0, workflow-cps (pipeline-groovy) 3601.v9b_36a_d99e1cc
Pipeline from SCM does not expand parameters or environment variables
Steps to reproduce:
- Create a new Pipeline with a String Parameter "PIPELINE_BRANCH"
- In the pipeline definition ; Select "Pipeline Script from SCM"
- Enter the repository URL
- In branch to build, enter the parameter : ${PIPELINE_BRANCH}
- Enter your script path
- Run the job with a valid branch
An error in thrown :
hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${PIPELINE_BRANCH}:refs/remotes/origin/${PIPELINE_BRANCH} --prune" returned status code 128:
stdout:
${PIPELINE_BRANCH} is not replaced by its value.
Same issue with an environment variable.
Expanding parameters/variable is working fine for a freestyle or matrix job.
- duplicates
-
JENKINS-28447 CpsScmFlowDefinition does not resolve variables
-
- Resolved
-
- is duplicated by
-
JENKINS-37681 PipelineScript from SCM is not accepting Parameters as input
-
- Resolved
-
-
JENKINS-36411 Cannot access environment variable from parameterized plugin in pipeline checkout
-
- Resolved
-
-
JENKINS-48431 Pipeline script from SCM should support build parameters using Lightweight checkout
-
- Closed
-
- is related to
-
JENKINS-48431 Pipeline script from SCM should support build parameters using Lightweight checkout
-
- Closed
-
-
JENKINS-49758 when passing in ref_spec with build parameters, the exact string "$REF_SPEC" is used rather then the value
-
- Open
-
-
JENKINS-60250 "Pipeline script from SCM": Git branch field cannot expand property from file
-
- Open
-
- relates to
-
JENKINS-70155 ReadTrusted fails when using Pipeline from SCM with a specific commit / Lightweight checkout fails when specifying single commit
-
- Open
-
-
JENKINS-42836 Build parameter not expanded in script path
-
- Resolved
-
- links to
martink89 first of all: fantastic job on getting this fixed. Works perfectly for me for regular pipeline jobs after updating to:
Your efforts are greatly appreciated!
I had hoped that this would also automatically fix the same issue for the Kubernetes plugin https://plugins.jenkins.io/kubernetes/ but no such luck unfortunately.
I have a simple pipeline job with "Pipeline script from SCM" (Git), the contents of which looks something like this:
Under the "Branches to build" settings, I have: "Branch Specifier (blank for 'any')": ${GIT_REF}
Unfortunately, when building with any GIT_REF build-parameter value, the result is:
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/${GIT_REF}:refs/remotes/origin/${GIT_REF}" returned status code 128: stderr: fatal: couldn't find remote ref refs/heads/${GIT_REF}
It doesn't matter if I choose "Lightweight checkout" or not. The result is the same. The all too familiar lack of variable substitution.
When using a regular (non-kubernetes) agent, it all works perfectly. Including lightweight checkout thanks to you.
Using a regular branch expression instead of a param/env var also works fine with the kubernetes agent obviously.
I'm not sure if you are familiar with the Kubernetes plugin or not. Should I inform the authors of your work on this issue so that they might implement it as well?