jenkinsci / jenkinsci/git-plugin

[JENKINS-46487] Git Plugin only scans refs/heads on multibranch scan

Open
#3,182 14 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

Because this was completely breaking my build environment, I was able to track down the issue to the following file: https://github.com/jenkinsci/git-plugin/blob/git-3.5.1/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java

Broken on sha a4febc060a23740816d660915b9fe0a7a6ffdcf6

Working on sha d7c3ece2553cf0494a56c766f62a6c9f340bbe4c

To get it to work in my environment, I reverted this one file to the previous sha and built the plugin locally. Installed on my Jenkins instance and the issue was fixed.

 

Issue:

For multibranch projects- not tested on single branch projects

Basically, when listing remotes during branch discovery, it forces the '-h' option for git ls-remotes and ignores any refspec given.

For example, I give the refspec '+refs/collab/:refs/remotes/origin/collab/' but it only lists (and therefore filters) remotes for '+refs/heads/:refs/remotes/origin/heads/'

Our org needs the custom refs location because that is how we automate code reviews.  On version 3.4.1 of the plugin, this refspec worked just fine.  On version 3.5.0, it broke and deleted all the collab branches.

Please let me know if you need any additional details.  I would submit a PR but, my Java is weak.  Thank you, kindly!

 

 

 

---
Originally reported by scatt, imported from: Git Plugin only scans refs/heads on multibranch scan


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

Raw content of original issue

Because this was completely breaking my build environment, I was able to track down the issue to the following file: https://github.com/jenkinsci/git-plugin/blob/git-3.5.1/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java

Broken on sha a4febc060a23740816d660915b9fe0a7a6ffdcf6

Working on sha d7c3ece2553cf0494a56c766f62a6c9f340bbe4c

To get it to work in my environment, I reverted this one file to the previous sha and built the plugin locally. Installed on my Jenkins instance and the issue was fixed.

 

Issue:

For multibranch projects- not tested on single branch projects

Basically, when listing remotes during branch discovery, it forces the '-h' option for git ls-remotes and ignores any refspec given.

For example, I give the refspec '+refs/collab/:refs/remotes/origin/collab/' but it only lists (and therefore filters) remotes for '+refs/heads/:refs/remotes/origin/heads/'

Our org needs the custom refs location because that is how we automate code reviews.  On version 3.4.1 of the plugin, this refspec worked just fine.  On version 3.5.0, it broke and deleted all the collab branches.

Please let me know if you need any additional details.  I would submit a PR but, my Java is weak.  Thank you, kindly!

 

 

 

environment

```
Jenkins 2.75

git-plugin 3.5.1
```

1 attachment

- [AbstractGitSCMSource.java](https://issues.jenkins.io/secure/attachment/39968/AbstractGitSCMSource.java)

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.