git-plugin icon indicating copy to clipboard operation
git-plugin copied to clipboard

[JENKINS-71742] Git fetch when pulling pod template fails when the "Branch Specifier" is an env var

Open jenkins-infra-bot opened this issue 2 years ago • 3 comments

I have a pipeline job that takes a branch as a parameter and then passes that value to the `Branch Specifier` like so: `${BRANCH}`.

The git plugin expands the value properly, but I believe that when the kubernetes plugin tries to do another checkout to read the pod template, it doesn't expand the variable and then fails.

 

 

 

Steps to reproduce:
1. Configure a pipeline job with a string parameter called `BRANCH`

2. For the pipeline definition, configure it to use "Pipeline script from SCM"
3. Use the `Git` SCM and configure it to point to your repo

4. `Branches to build` -> `Branch Specifier` - should be set to `${BRANCH}` or whatever your parameter is called

5. Specify your Jenkinsfile path
– Specify the pod template using `yamlFile`
6. `Lightweight checkout` should be unchecked

7. Attempt to build the job

 

Stripped down version of my jenkinsfile: Jenkinsfile

 


Originally reported by thnguyen, imported from: Git fetch when pulling pod template fails when the "Branch Specifier" is an env var
  • status: Open
  • priority: Major
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 2025-12-02
Raw content of original issue

I have a pipeline job that takes a branch as a parameter and then passes that value to the `Branch Specifier` like so: `${BRANCH}`.

The git plugin expands the value properly, but I believe that when the kubernetes plugin tries to do another checkout to read the pod template, it doesn't expand the variable and then fails.

 

 

 

Steps to reproduce: 1. Configure a pipeline job with a string parameter called `BRANCH`

2. For the pipeline definition, configure it to use "Pipeline script from SCM" 3. Use the `Git` SCM and configure it to point to your repo 4. `Branches to build` -> `Branch Specifier` - should be set to `${BRANCH}` or whatever your parameter is called 5. Specify your Jenkinsfile path – Specify the pod template using `yamlFile` 6. `Lightweight checkout` should be unchecked 7. Attempt to build the job

 

Stripped down version of my jenkinsfile: Jenkinsfile

 

6 attachments

jenkins-infra-bot avatar Jul 31 '23 19:07 jenkins-infra-bot

thnguyen:
  • Original comment link
  • Raw content of original comment:

    Hi markewaite, is there any additional information I can provide to help with this? Thanks!

Hi markewaite, is there any additional information I can provide to help with this? Thanks!

jenkins-infra-bot avatar Apr 25 '24 22:04 jenkins-infra-bot

markewaite:
  • Original comment link
  • Raw content of original comment:

    thnguyen I don't plan to investigate this. I don't have easy access to a Kubernetes cluster with a YAML template. I assume the issue is in the kubernetes plugin rather than in the git plugin, but I'm not planning to investigate that in order to confirm my theory.

thnguyen I don't plan to investigate this. I don't have easy access to a Kubernetes cluster with a YAML template. I assume the issue is in the kubernetes plugin rather than in the git plugin, but I'm not planning to investigate that in order to confirm my theory.

jenkins-infra-bot avatar Apr 27 '24 15:04 jenkins-infra-bot

snup67:
  • Original comment link
  • Raw content of original comment:

    This bug is not related to Kubernetes. It related to jenkins job itself that not inherit the parameter value to Branch specifier and result of that is the git fetch command  that uses ${BRANCH) as string instead of the value parameter.

    See the git fetch command in the Screenshot with the log snapshot that uploaded here

    I'm also facing that behave.

This bug is not related to Kubernetes.
It related to jenkins job itself that not inherit the parameter value to Branch specifier and result of that is the git fetch command  that uses ${BRANCH) as string instead of the value parameter.

See the git fetch command in the Screenshot with the log snapshot that uploaded here

I'm also facing that behave.

jenkins-infra-bot avatar Oct 29 '25 06:10 jenkins-infra-bot