jenkinsci / jenkinsci/git-plugin
[JENKINS-67073] Jenkins is not using the correct commit SHA when building a force pushed PR
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
- When force pushing a pull request branch via bitbucket, jenkins keeps building the first commit that the pull request was created with.
- Bitbucket-push-and-pull-request-plugin on jenkins receives the payload from the webhook correctly and the build is triggered but the commit which jenkins fetches is wrong.
- Steps to reproduce:
- Push a PR and check if the build is triggered in jenkins via bitbucket-push-and-pull-request-plugin.
- Check the sha of the commit in bitbucket PR commit summary.
- Make a code change, commit amend and force push the change (you will see that the commit sha has changed in the PR overview).
- Check that jenkins has been triggered and you will see that the build fail with error (stderr: fatal: reference is not a tree: a5b47104e757b867e58f0e564b439e8d2f770ed6) or whatever commit sha you have
hudson.plugins.git.GitException: Command "/usr/bin/git checkout -f a5b47104e757b867e58f0e564b439e8d2f770ed6" returned status code 128:
stdout:
stderr: fatal: reference is not a tree: a5b47104e757b867e58f0e564b439e8d2f770ed6 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$1100(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2999)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from my server
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1797)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:1001)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
at com.sun.proxy.$Proxy95.execute(Unknown Source)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1352)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused: hudson.plugins.git.GitException: Could not checkout a5b47104e757b867e58f0e564b439e8d2f770ed6
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:3023)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:160)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:153)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
at java.base/java.lang.Thread.run(Thread.java:834)
Finished: FAILURE
The sha1 of the latest commit is different from a5b47104e757b867e58f0e564b439e8d2f770ed6
the git plugin as well as bitbucket-pull-request-plugin were configured to listen to any branch's change
---
Originally reported by kafteji, imported from: Jenkins is not using the correct commit SHA when building a force pushed PR
Raw content of original issue
- When force pushing a pull request branch via bitbucket, jenkins keeps building the first commit that the pull request was created with.
- Bitbucket-push-and-pull-request-plugin on jenkins receives the payload from the webhook correctly and the build is triggered but the commit which jenkins fetches is wrong.
- Steps to reproduce:
- Push a PR and check if the build is triggered in jenkins via bitbucket-push-and-pull-request-plugin.
- Check the sha of the commit in bitbucket PR commit summary.
- Make a code change, commit amend and force push the change (you will see that the commit sha has changed in the PR overview).
- Check that jenkins has been triggered and you will see that the build fail with error (stderr: fatal: reference is not a tree: a5b47104e757b867e58f0e564b439e8d2f770ed6) or whatever commit sha you have
hudson.plugins.git.GitException: Command "/usr/bin/git checkout -f a5b47104e757b867e58f0e564b439e8d2f770ed6" returned status code 128:
stdout:
stderr: fatal: reference is not a tree: a5b47104e757b867e58f0e564b439e8d2f770ed6 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2681)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$1100(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2999)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from my server
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1797)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:1001)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
at com.sun.proxy.$Proxy95.execute(Unknown Source)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1352)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused: hudson.plugins.git.GitException: Could not checkout a5b47104e757b867e58f0e564b439e8d2f770ed6
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:3023)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:160)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:153)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
at java.base/java.lang.Thread.run(Thread.java:834)
Finished: FAILURE
The sha1 of the latest commit is different from a5b47104e757b867e58f0e564b439e8d2f770ed6
the git plugin as well as bitbucket-pull-request-plugin were configured to listen to any branch's change
environment
```
Jenkins: LTS 2.303.3
git-plugin: 4.10.0
bitbucket-push-and-pull-request-plugin: 2.7.2
```
Contributor guide
Assessment
This issue has not been assessed yet.