jenkinsci / jenkinsci/git-client-plugin

[JENKINS-31686] Jenkins injects the old git commit as GIT_COMMIT env variable

Open
#1,500 6 comments 0 reactions 0 assignees View on GitHub
component:ghprb-plugin component:git-client-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
152
Forks
402
Avg merge
6h 47m
Merged PRs (30d)
4

Description

Compare GIT_COMMIT, GIT_PREVIOUS_COMMIT with ghprbActualCommit

GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.

GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.

Setting status of 91cdd0e62caf929448a09caf57df9f99bc7dafd6 to PENDING with url http://jenkins.net:8080/job/build-on-PR/82/ and message: 'Build started sha1 is merged.'

[EnvInject] - Loading node environment variables.

Building on master in workspace /var/lib/jenkins/workspace/build-on-PR

[WS-CLEANUP] Deleting project workspace...

[WS-CLEANUP] Done

Cloning the remote Git repository

Cloning repository git@​github.com:example/com.git

> git init /var/lib/jenkins/workspace/build-on-PR/src/github.com/example/com # timeout=10

Fetching upstream changes from git@​github.com:example/com.git

> git --version # timeout=10

using GIT_SSH to set credentials Used for Github integration

> git -c core.askpass=true fetch --tags --progress git@​github.com:example/com.git +refs/heads/:refs/remotes/origin/

> git config remote.origin.url git@​github.com:example/com.git # timeout=10

> git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10

> git config remote.origin.url git@​github.com:example/com.git # timeout=10

Fetching upstream changes from git@​github.com:example/com.git

using GIT_SSH to set credentials Used for Github integration

> git -c core.askpass=true fetch --tags --progress git@​github.com:example/com.git +refs/heads/:refs/remotes/origin/ +refs/pull/:refs/remotes/origin/pr/

> git rev-parse 91cdd0e62caf929448a09caf57df9f99bc7dafd6^


{commit}

# timeout=10

Checking out Revision 91cdd0e62caf929448a09caf57df9f99bc7dafd6 (detached)

> git config core.sparsecheckout # timeout=10

> git checkout -f 91cdd0e62caf929448a09caf57df9f99bc7dafd6

> git rev-list 37b91ca3808f0fe9ae726c1562c1deddd5652ea0 # timeout=10


[build-on-PR] $ /bin/bash /tmp/hudson4235424762063686423.sh

+ export PROJECTIMPORTPATH=github.com/example/com

+ PROJECTIMPORTPATH=github.com/example/com

+ sort

+ env

BUILD_CAUSE=GHPRBCAUSE,GHPRBCAUSE

BUILD_CAUSE_GHPRBCAUSE=true

BUILD_DISPLAY_NAME=#82

BUILD_ID=82

BUILD_NUMBER=82

BUILD_TAG=jenkins-build-on-PR-82

BUILD_URL=http://jenkins.net:8080/job/build-on-PR/82/

EXECUTOR_NUMBER=0

GIT_AUTHOR_EMAIL=dev+jenkinsbot@​example.com

GIT_AUTHOR_NAME=yoyojenkinsbot

GIT_BRANCH=item-598

GIT_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0

GIT_COMMITTER_EMAIL=dev+jenkinsbot@​jenkins.example.net.com

GIT_COMMITTER_NAME=yoyojenkinsbot

GIT_PREVIOUS_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0

GIT_PREVIOUS_SUCCESSFUL_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0

GIT_URL=git@​github.com:example/com.git

GOROOT=/usr/local/go/1.5.1

HOME=/var/lib/jenkins

HUDSON_COOKIE=9bf6d035-21a3-480c-b345-3fc7245e160v

HUDSON_HOME=/var/lib/jenkins

HUDSON_SERVER_COOKIE=3fc7dd345e6d2e33

HUDSON_URL=http://jenkins.net:8080/

JENKINS_HOME=/var/lib/jenkins

JENKINS_SCRIPTS=/var/lib/jenkins/workspace/jenkins-scripts/jenkins-scripts

JENKINS_SERVER_COOKIE=3fc7dd720e6d2e56

JENKINS_URL=http://jenkins.net:8080/

JOB_NAME=build-on-PR

JOB_URL=http://jenkins.net:8080/job/build-on-PR/

LANG=en_US.UTF-8

LC_COLLATE=C

LOGNAME=jenkins

MAIL=/var/mail/jenkins

NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat

NODE_LABELS=go master master,

NODE_NAME=master

PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/var/lib/jenkins/go/bin

PDIR=src/github.com/example/com

PROJECTIMPORTPATH=github.com/example/com

PROJECTNAME=ms-psps

PWD=/var/lib/jenkins/workspace/build-on-PR

ROOT_BUILD_CAUSE=GHPRBCAUSE

ROOT_BUILD_CAUSE_GHPRBCAUSE=true

SHELL=/bin/bash

SHLVL=2

TERM=xterm-256color

USER=jenkins

WORKSPACE=/var/lib/jenkins/workspace/build-on-PR

XDG_RUNTIME_DIR=/run/user/1000

XDG_SESSION_ID=23

XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt

_=/usr/bin/env

ghprbActualCommit=91cdd0e62caf929448a09caf57df9f99bc7dafd6

ghprbActualCommitAuthor=Dev1

ghprbActualCommitAuthorEmail=dev1@​example.com

ghprbAuthorRepoGitUrl=https://github.com/example/com.git

ghprbCommentBody=test this please

ghprbCredentialsId=6da1257c-1f41-4b30-ba9e-03af2f772ad1

ghprbGhRepository=example/com

ghprbPullAuthorLogin=dev1

ghprbPullAuthorLoginMention=@​dev1

ghprbPullDescription=GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.

ghprbPullId=21

ghprbPullLink=https://github.com/example/com/pull/21

ghprbPullLongDescription=null

ghprbPullTitle=New backend feature

ghprbSourceBranch=item-598

ghprbTargetBranch=master

ghprbTriggerAuthor=Dev1

ghprbTriggerAuthorLogin=dev1

ghprbTriggerAuthorLoginMention=@​dev1

sha1=origin/pr/21/merge

---
Originally reported by kowalcj0, imported from: Jenkins injects the old git commit as GIT_COMMIT env variable


  • status: Open
  • priority: Major
  • component(s): ghprb-plugin, git-client-plugin
  • label(s): git, git-client
  • resolution: Unresolved
  • votes: 2
  • watchers: 7
  • imported: 20251211-071809

Raw content of original issue

Compare GIT_COMMIT, GIT_PREVIOUS_COMMIT with ghprbActualCommit

GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
Setting status of 91cdd0e62caf929448a09caf57df9f99bc7dafd6 to PENDING with url http://jenkins.net:8080/job/build-on-PR/82/ and message: 'Build started sha1 is merged.'
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/lib/jenkins/workspace/build-on-PR
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Cloning the remote Git repository
Cloning repository git@github.com:example/com.git
> git init /var/lib/jenkins/workspace/build-on-PR/src/github.com/example/com # timeout=10
Fetching upstream changes from git@github.com:example/com.git
> git --version # timeout=10
using GIT_SSH to set credentials Used for Github integration
> git -c core.askpass=true fetch --tags --progress git@github.com:example/com.git +refs/heads/:refs/remotes/origin/
> git config remote.origin.url git@github.com:example/com.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10
> git config remote.origin.url git@github.com:example/com.git # timeout=10
Fetching upstream changes from git@github.com:example/com.git
using GIT_SSH to set credentials Used for Github integration
> git -c core.askpass=true fetch --tags --progress git@github.com:example/com.git +refs/heads/:refs/remotes/origin/ +refs/pull/:refs/remotes/origin/pr/
> git rev-parse 91cdd0e62caf929448a09caf57df9f99bc7dafd6^


{commit}

# timeout=10
Checking out Revision 91cdd0e62caf929448a09caf57df9f99bc7dafd6 (detached)
> git config core.sparsecheckout # timeout=10
> git checkout -f 91cdd0e62caf929448a09caf57df9f99bc7dafd6
> git rev-list 37b91ca3808f0fe9ae726c1562c1deddd5652ea0 # timeout=10

[build-on-PR] $ /bin/bash /tmp/hudson4235424762063686423.sh
+ export PROJECTIMPORTPATH=github.com/example/com
+ PROJECTIMPORTPATH=github.com/example/com
+ sort
+ env
BUILD_CAUSE=GHPRBCAUSE,GHPRBCAUSE
BUILD_CAUSE_GHPRBCAUSE=true
BUILD_DISPLAY_NAME=#82
BUILD_ID=82
BUILD_NUMBER=82
BUILD_TAG=jenkins-build-on-PR-82
BUILD_URL=http://jenkins.net:8080/job/build-on-PR/82/
EXECUTOR_NUMBER=0
GIT_AUTHOR_EMAIL=dev+jenkinsbot@example.com
GIT_AUTHOR_NAME=yoyojenkinsbot
GIT_BRANCH=item-598
GIT_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
GIT_COMMITTER_EMAIL=dev+jenkinsbot@jenkins.example.net.com
GIT_COMMITTER_NAME=yoyojenkinsbot
GIT_PREVIOUS_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
GIT_PREVIOUS_SUCCESSFUL_COMMIT=37b91ca3808f0fe9ae726c1562c1deddd5652ea0
GIT_URL=git@github.com:example/com.git
GOROOT=/usr/local/go/1.5.1
HOME=/var/lib/jenkins
HUDSON_COOKIE=9bf6d035-21a3-480c-b345-3fc7245e160v
HUDSON_HOME=/var/lib/jenkins
HUDSON_SERVER_COOKIE=3fc7dd345e6d2e33
HUDSON_URL=http://jenkins.net:8080/
JENKINS_HOME=/var/lib/jenkins
JENKINS_SCRIPTS=/var/lib/jenkins/workspace/jenkins-scripts/jenkins-scripts
JENKINS_SERVER_COOKIE=3fc7dd720e6d2e56
JENKINS_URL=http://jenkins.net:8080/
JOB_NAME=build-on-PR
JOB_URL=http://jenkins.net:8080/job/build-on-PR/
LANG=en_US.UTF-8
LC_COLLATE=C
LOGNAME=jenkins
MAIL=/var/mail/jenkins
NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
NODE_LABELS=go master master,
NODE_NAME=master
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/var/lib/jenkins/go/bin
PDIR=src/github.com/example/com
PROJECTIMPORTPATH=github.com/example/com
PROJECTNAME=ms-psps
PWD=/var/lib/jenkins/workspace/build-on-PR
ROOT_BUILD_CAUSE=GHPRBCAUSE
ROOT_BUILD_CAUSE_GHPRBCAUSE=true
SHELL=/bin/bash
SHLVL=2
TERM=xterm-256color
USER=jenkins
WORKSPACE=/var/lib/jenkins/workspace/build-on-PR
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_ID=23
XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
_=/usr/bin/env
ghprbActualCommit=91cdd0e62caf929448a09caf57df9f99bc7dafd6
ghprbActualCommitAuthor=Dev1
ghprbActualCommitAuthorEmail=dev1@example.com
ghprbAuthorRepoGitUrl=https://github.com/example/com.git
ghprbCommentBody=test this please
ghprbCredentialsId=6da1257c-1f41-4b30-ba9e-03af2f772ad1
ghprbGhRepository=example/com
ghprbPullAuthorLogin=dev1
ghprbPullAuthorLoginMention=@dev1
ghprbPullDescription=GitHub pull request #21 of commit 91cdd0e62caf929448a09caf57df9f99bc7dafd6, no merge conflicts.
ghprbPullId=21
ghprbPullLink=https://github.com/example/com/pull/21
ghprbPullLongDescription=null
ghprbPullTitle=New backend feature
ghprbSourceBranch=item-598
ghprbTargetBranch=master
ghprbTriggerAuthor=Dev1
ghprbTriggerAuthorLogin=dev1
ghprbTriggerAuthorLoginMention=@dev1
sha1=origin/pr/21/merge

environment

```
Jenkins v1.638

Oracle Java 1.8.0_66

Ubuntu 3.13.0-48-generic x86_64
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.