[JIRA] (JENKINS-61317) env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo), can not get the right GIT_COMMIT

19 views
Skip to first unread message

foreverbonfy@gmail.com (JIRA)

unread,
Mar 3, 2020, 11:38:02 PM3/3/20
to jenkinsc...@googlegroups.com
bon ch created an issue
 
Jenkins / Bug JENKINS-61317
env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo), can not get the right GIT_COMMIT
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2020-03-04 04:37
Priority: Major Major
Reporter: bon ch

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

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Mar 3, 2020, 11:44:01 PM3/3/20
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
Mar 3, 2020, 11:46:04 PM3/3/20
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-61317
 
Re: env.GIT_COMMIT is overwritten when pull lib (lib and code in the same repo), can not get the right GIT_COMMIT

Please provide an example pipeline which shows the issue using a publicly accessible git repository.

foreverbonfy@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:29:03 AM3/4/20
to jenkinsc...@googlegroups.com
bon ch commented on Bug JENKINS-61317

Mark Waite

I create example repo to this issue: https://github.com/bonfy/JENKINS-61317

Jenkinsfile in master branch Last commit : 64dd9920
library in jenkins-lib branch Last commit: a8c235b1

and when echo GIT_COMMIT, it is overwitten by lib's commit

[Pipeline] echo
13:22:18 stage 1
[Pipeline] echo
13:22:18 GIT COMMIT : a8c235b10c55e2f065293b1c1ad9b3bffd45d9d9
[Pipeline] echo
13:22:18 Hello world
[Pipeline] }

 

mark.earl.waite@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:45:03 AM3/4/20
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:47:03 AM3/4/20
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-61317
Thank you.   Until a fix is available for the issue, you can use the {{returnStdout}} capability of the {{sh}} and {{bat}} and {{powershell}} commands to call {{git rev-parse HEAD}}

foreverbonfy@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:58:02 AM3/4/20
to jenkinsc...@googlegroups.com

foreverbonfy@gmail.com (JIRA)

unread,
Mar 4, 2020, 4:03:02 AM3/4/20
to jenkinsc...@googlegroups.com
bon ch commented on Bug JENKINS-61317

Mark Waite

 

I update the repo https://github.com/bonfy/JENKINS-61317

Add echo env.GIT_BRANCH, and find that the GIT_BRANCH is also overwritten, maybe other git related env valuables as well.  So maybe you can check and fix them together.

 

the Jenkins console output now looks like: 

 

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

 

Thanks

foreverbonfy@gmail.com (JIRA)

unread,
Mar 4, 2020, 4:14:02 AM3/4/20
to jenkinsc...@googlegroups.com
bon ch updated an issue
 
Change By: bon ch
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

[Pipeline] echo
13:22:18 stage 1
[Pipeline] echo
13:22:18 GIT COMMIT : a8c235b10c55e2f065293b1c1ad9b3bffd45d9d9
[Pipeline] echo

13:22:18 Hello world
[Pipeline] }

 

foreverbonfy@gmail.com (JIRA)

unread,
Mar 4, 2020, 4:15:03 AM3/4/20
to jenkinsc...@googlegroups.com
bon ch updated an 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: a8c235b1

and when echo GIT_COMMIT, it is overwitten by lib's commit

[Pipeline] echo
13
16 : 22 55 : 18 47 stage 1
[Pipeline] echo
13 16 : 22 55 : 18 47 GIT COMMIT : a8c235b10c55e2f065293b1c1ad9b3bffd45d9d9
[Pipeline] echo
13 16 : 22 55 : 18 Hello world 47 GIT BRANCH : jenkins-lib
[Pipeline] 
} echo
16:55:48 Hello world

 
Reply all
Reply to author
Forward
0 new messages