jenkinsci / jenkinsci/git-plugin

[JENKINS-31865] Jenkins builds incorrect branch when regex branch specifier changes

Open
#2,768 1 comment 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

Today I noticed what seems to be a bug in Jenkins/git-plugin due to some sort of caching(??)


  • create new freestyle project

  • use git scm

  • specify a regex branch specifier, eg. :origin/master

  • save and build

  • update project, changing the branch specifier, eg. :origin/yolo

  • save and build

  • update the project, changing the branch specifier back to the original, eg. :origin/master

  • save and build

I'd expect the last build to be master, but it really just checks out the previous branch :origin/yolo.

I came across this when I tried using a parameterized build setup to build multiple branches :origin/(master|v.*) on scm change, with the option to manually specify a branch to build via the parameter. However, after changing the branch specifier in this case, Jenkins/git-plugin seems to get stuck on one branch :o.

Let me know if I can help with any other details.

---
Originally reported by wilrnh, imported from: Jenkins builds incorrect branch when regex branch specifier changes


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

Raw content of original issue

Today I noticed what seems to be a bug in Jenkins/git-plugin due to some sort of caching(??)


  • create new freestyle project

  • use git scm

  • specify a regex branch specifier, eg. :origin/master

  • save and build

  • update project, changing the branch specifier, eg. :origin/yolo

  • save and build

  • update the project, changing the branch specifier back to the original, eg. :origin/master

  • save and build

I'd expect the last build to be master, but it really just checks out the previous branch :origin/yolo.

I came across this when I tried using a parameterized build setup to build multiple branches :origin/(master|v.*) on scm change, with the option to manually specify a branch to build via the parameter. However, after changing the branch specifier in this case, Jenkins/git-plugin seems to get stuck on one branch :o.

Let me know if I can help with any other details.

environment

```
git-plugin 2.4.0

Jenkins ver. 1.626

```

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.