-
Bug
-
Resolution: Won't Fix
-
Major
-
Git Plugin 2.2.7, Jenkins 1.509.2
I have a job configured with "branches to build" as "origin/release/flow". The polling log shows that the git plugin is erroneously only using the last component of the branch name to poll:
git ls-remote -h git@github.mycompany.lan:org/Repo.git flow # timeout=10
This matches six branches on the server. The plugin uses the first one, which is "refs/heads/appstore/flow". The hashes never match, so the plugin triggers the build every time.
As a workaround I've changed "branches to build" to "refs/heads/release/flow", but this should be fixed.
Thanks for your comments. Unfortunately, it can't be fixed without a significant risk of breaking compatibility with many of the existing users of the git plugin.
That simplified syntax is used by many jobs in many locations and changing its behavior is likely to have many unintended side effects. That is why Alexander Link's changes to allow refs/heads syntax were used instead of altering the behavior of the existing syntax. The refs/heads syntax allows unambiguous specification of the branch name without altering the meaning of the existing simplified syntax.
That is also why the description of the regex form of branch specification was added to the online help about the same time. The regex form of branch specification had been in the code for quite a while, without online help, when Alexander and I discovered it lurking there. Since it was in the code, we included it in the online help as another way of handling this condition.
There are too many users of the git plugin using it in too many diverse and interesting ways for us to change so fundamental a behavior, even if the behavior seems flawed.
For a good discussion of the challenges associated with the branches to build specification, refer to commit 1, commit 2, commit 3, commit 4, and commit 5