jenkinsci / jenkinsci/git-plugin
[JENKINS-63550] Git checkouts last built branch instead of specified "branch to build" when no change in branch
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
I have a parameterized job which can build several Git branch. The "branch to build" is taken as job parameter.

Starting from a new job, firstly I build branch A, and then branch B. Then I'd like to rebuild branch A, without any commit in any branch in the meanwhile. But when I launch the build with branch A as parameter, Jenkins still checkouts the last built branch (B).
I suppose that Git plugin compare the SHA of the latest built commit with the SHA of the latest commit on remote branch: if this is different, all works as expected (checkout on the specified branch A), but if this is the same it still checkouts the last built branch B (why??).
If I purge Git Build Data as described here (https://plugins.jenkins.io/git/#remove-git-plugin-buildsbybranch-builddata-script) I can rebuild branch A (but I cannot do this purge anytime!)
Jenkins version: 2.164.3
Git plugin version: 4.2.2
Git client plugin version: 3.2.1
Job Type: Maven job
---
Originally reported by morettileo, imported from: Git checkouts last built branch instead of specified "branch to build" when no change in branch
Raw content of original issue
I have a parameterized job which can build several Git branch. The "branch to build" is taken as job parameter.
Starting from a new job, firstly I build branch A, and then branch B. Then I'd like to rebuild branch A, without any commit in any branch in the meanwhile. But when I launch the build with branch A as parameter, Jenkins still checkouts the last built branch (B).
I suppose that Git plugin compare the SHA of the latest built commit with the SHA of the latest commit on remote branch: if this is different, all works as expected (checkout on the specified branch A), but if this is the same it still checkouts the last built branch B (why??).
If I purge Git Build Data as described here (https://plugins.jenkins.io/git/#remove-git-plugin-buildsbybranch-builddata-script) I can rebuild branch A (but I cannot do this purge anytime!)
Jenkins version: 2.164.3
Git plugin version: 4.2.2
Git client plugin version: 3.2.1
Job Type: Maven job
1 attachment
- [image-2020-08-28-14-43-51-924.png](https://issues.jenkins.io/secure/attachment/52469/image-2020-08-28-14-43-51-924.png)
> 
Contributor guide
Assessment
This issue has not been assessed yet.