jenkinsci / jenkinsci/git-plugin
[JENKINS-61317] env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo), can not get the right GIT_COMMIT
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo)
SharedLibrary put in the same code repo, different branch named xxx_lib, and after Declarative: Checkout SCM, can not get the right GIT_COMMIT, always be the xxx_lib's last commit, not the code's commit
I create example repo to this issue: https://github.com/bonfy/JENKINS-61317
Jenkinsfile in master branch Last commit: 39f25e1a
library in jenkins-lib branch Last commit: a8c235b1
and when echo GIT_COMMIT, it is overwitten by lib's commit
16:55:47 stage 1
[Pipeline] echo
16:55:47 GIT COMMIT : a8c235b10c55e2f065293b1c1ad9b3bffd45d9d9
[Pipeline] echo
16:55:47 GIT BRANCH : jenkins-lib
[Pipeline] echo
16:55:48 Hello world
---
Originally reported by
bonfy, imported from: env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo), can not get the right GIT_COMMIT
Raw content of original issue
env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo)
SharedLibrary put in the same code repo, different branch named xxx_lib, and after Declarative: Checkout SCM, can not get the right GIT_COMMIT, always be the xxx_lib's last commit, not the code's commit
I create example repo to this issue: https://github.com/bonfy/JENKINS-61317
Jenkinsfile in master branch Last commit: 39f25e1a
library in jenkins-lib branch Last commit: a8c235b1and when echo GIT_COMMIT, it is overwitten by lib's commit
16:55:47 stage 1
[Pipeline] echo
16:55:47 GIT COMMIT : a8c235b10c55e2f065293b1c1ad9b3bffd45d9d9
[Pipeline] echo
16:55:47 GIT BRANCH : jenkins-lib
[Pipeline] echo
16:55:48 Hello world
Contributor guide
Assessment
This issue has not been assessed yet.