jenkinsci / jenkinsci/git-plugin

[JENKINS-49758] when passing in ref_spec with build parameters, the exact string "$REF_SPEC" is used rather then the value

Open
#3,270 4 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

To replicate:

1) create a job and pass in refspec as build parameter e.g. "$GIT_REFSPEC"

2) use the parameter "$GIT_REFSPEC" as the SCM configuration for git-plugin

3) The build will use the exact string "$GIT_REFSPEC" rather than the actual value of $GIT_REFSPEC for the fetch operation.

For example:

01:26:08 using GIT_SSH to set credentials Gerrit SSH Key

01:26:08 > /usr/bin/git fetch --no-tags --progress ssh://[github-project-url] $GIT_REFSPEC --depth=2

01:31:43 > /usr/bin/git config remote.origin.url ssh://[github-project-url] # timeout=10

01:31:43 > /usr/bin/git config --add remote.origin.fetch $GIT_REFSPEC # timeout=10

 

I believe the .toString in this line is causing this problem:

https://github.com/jenkinsci/git-client-plugin/blob/4241e818dbe27fb78093094f29ebcd2203166610/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L617

---
Originally reported by slcy, imported from: when passing in ref_spec with build parameters, the exact string "$REF_SPEC" is used rather then the value


  • status: Open
  • priority: Major
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 10
  • watchers: 12
  • imported: 2025-12-02

Raw content of original issue

To replicate:

1) create a job and pass in refspec as build parameter e.g. "$GIT_REFSPEC"

2) use the parameter "$GIT_REFSPEC" as the SCM configuration for git-plugin

3) The build will use the exact string "$GIT_REFSPEC" rather than the actual value of $GIT_REFSPEC for the fetch operation.

For example:
01:26:08 using GIT_SSH to set credentials Gerrit SSH Key
01:26:08 > /usr/bin/git fetch --no-tags --progress ssh://[github-project-url] $GIT_REFSPEC --depth=2
01:31:43 > /usr/bin/git config remote.origin.url ssh://[github-project-url] # timeout=10
01:31:43 > /usr/bin/git config --add remote.origin.fetch $GIT_REFSPEC # timeout=10
 

I believe the .toString in this line is causing this problem:

https://github.com/jenkinsci/git-client-plugin/blob/4241e818dbe27fb78093094f29ebcd2203166610/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L617

2 attachments

- [image-2019-09-26-16-32-02-026.png](https://issues.jenkins.io/secure/attachment/48866/image-2019-09-26-16-32-02-026.png)
> ![image-2019-09-26-16-32-02-026.png](https://issues.jenkins.io/secure/attachment/48866/image-2019-09-26-16-32-02-026.png)
- [image-2019-09-26-16-34-33-817.png](https://issues.jenkins.io/secure/attachment/48867/image-2019-09-26-16-34-33-817.png)
> ![image-2019-09-26-16-34-33-817.png](https://issues.jenkins.io/secure/attachment/48867/image-2019-09-26-16-34-33-817.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.