jenkinsci / jenkinsci/git-plugin

[JENKINS-54102] Endless builds with local branch checked out

Open
#3,354 2 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

When a local branch is checked out with name matching a remote branch, and the remote branch is rewritten, endless builds are triggered. This happens because the plugin finds multiple matching revisions, one in the local and one in the remote branch:



Multiple candidate revisions

Scheduling another build to catch up with

This can be solved by using the fully qualified remote branch name as specifier, i.e. "remotes/origin/branchname". But this is not possible in my case since the branch name is generated by the multibranch plugin.

A simple fix might be to delete the automatic local branch before trying to match branch names; the local branch is anyway deleted a bit later, before it is recreated:

Multiple candidate revisions

Scheduling another build to catch up with
Checking out Revision ()
> git config core.sparsecheckout # timeout=10
> git checkout -f
> git branch -a -v --no-abbrev # timeout=10
> git branch -D # timeout=10
> git checkout -b

...or, alternatively, exclude the automatic local branch explicitly from the branch name matching.

 

---
Originally reported by jobh, imported from: Endless builds with local branch checked out


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

Raw content of original issue

When a local branch is checked out with name matching a remote branch, and the remote branch is rewritten, endless builds are triggered. This happens because the plugin finds multiple matching revisions, one in the local and one in the remote branch:



Multiple candidate revisions

Scheduling another build to catch up with <build name>

This can be solved by using the fully qualified remote branch name as specifier, i.e. "remotes/origin/branchname". But this is not possible in my case since the branch name is generated by the multibranch plugin.

A simple fix might be to delete the automatic local branch before trying to match branch names; the local branch is anyway deleted a bit later, before it is recreated:



Multiple candidate revisions

Scheduling another build to catch up with <build name>
Checking out Revision <revision> (<local branch name>)
> git config core.sparsecheckout # timeout=10
> git checkout -f <revision>
> git branch -a -v --no-abbrev # timeout=10
> git branch -D <local branch name> # timeout=10
> git checkout -b <local branch name> <revision>


...or, alternatively, exclude the automatic local branch explicitly from the branch name matching.

 

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.