-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.107.1, git-plugin 2.7.1
If the git plugin uses a local branch which is named the same as the remote and contains a forward slash, it will cause the checkout command to not update to the latest commit. Since using branches with / is common and local branch might be necessary, this should be fixed or at least produce a warning.
To test: Create the following pipeline:
node { stage ('hello') { dir ('foo') { checkout([$class: 'GitSCM', branches: [[name: "foo/bar"]], extensions: [[$class: 'LocalBranch', localBranch: 'foo/bar']], userRemoteConfigs: [[credentialsId: '...', url: "..."]]]) } } }
And follow these steps:
- Push branch foo/bar
- Run pipeline
- Push branch foo/bar with new versions
- Re-run pipeline in same folder
The output should have the following contents:
> git.exe fetch --tags --progress ssh://xxxx +refs/heads/*:refs/remotes/origin/* > git.exe rev-parse "foo/bar^{commit}" # timeout=10 > git.exe rev-parse "refs/remotes/origin/foo/bar^{commit}" # timeout=10 Multiple candidate revisions Checking out Revision 7bbd0143e31f1280e032cf350cf9f466642d1d65 (foo/bar)
The 7bbd014 is the older commit however, since the local branch takes precedence over the remote one.
Workarounds:
- Name the local branch differently from the remote branch
- Specify the fully quialified branch name (remotes/origin/${branch}) in the checkout command
- duplicates
-
JENKINS-37263 Jenkins checkout the wrong commit when used with the local branch behaviour on a branch with a / (slash)
- Closed
- relates to
-
JENKINS-50556 git polling succeeds even when origin/master has nothing new
- Open