Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46878

Merge before build behavior isn't executed on slaves

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Git client plugin 2.5.0
      Git plugin 3.5.1
      Git PreBuildMerge Trait Plugin 1.0

      I'm having a build that works on the master but not on a slave. It seems as if the merge before build behavior isn't executed on the slave. The error I get on the slave is

       

      Checking out Revision 0f54a3f1e1c0648f9488d4d3405080f7d5cbf02b (origin/master)
      org.eclipse.jgit.errors.MissingObjectException: Missing unknown 0f54a3f1e1c0648f9488d4d3405080f7d5cbf02b
      	at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:158)
      	at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:227)
      	at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:859)
      	at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:772)
      	at hudson.plugins.git.util.RevCommitRepositoryCallback.invoke(RevCommitRepositoryCallback.java:25)
      	at hudson.plugins.git.util.RevCommitRepositoryCallback.invoke(RevCommitRepositoryCallback.java:13)
      	at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:71)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:895)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:870)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:829)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:153)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
      	at hudson.remoting.Request$2.run(Request.java:336)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at hudson.remoting.Engine$1$1.run(Engine.java:94)
      	at java.lang.Thread.run(Thread.java:745)
      	at ......remote call to JNLP4-connect connection from cpbec-pc.telit.telit.at/10.70.34.7:62685(Native Method)
      	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
      	at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
      	at hudson.remoting.Channel.call(Channel.java:830)
      	at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:257)
      	at com.sun.proxy.$Proxy55.withRepository(Unknown Source)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl.withRepository(RemoteGitImpl.java:235)
      	at hudson.plugins.git.GitSCM.printCommitMessageToLog(GitSCM.java:1195)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1159)
      	at hudson.scm.SCM.checkout(SCM.java:496)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1281)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      	at hudson.model.Run.execute(Run.java:1728)
      	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:405)

       

      I found out that the commit SHA refers to the merge commit that is apparently not created on the slave.

      Any clues how I could workaround this in the meantime?

          [JENKINS-46878] Merge before build behavior isn't executed on slaves

          Mark Waite added a comment -

          You might check that the refspec used to clone the repository on the agent is sufficient to include the commit you're trying to reference in the merge. If you're merging from one branch to another, then it seems like you'll need a non-default refspec, since you'll need both the source branch and the destination branch in the workspace.

          Mark Waite added a comment - You might check that the refspec used to clone the repository on the agent is sufficient to include the commit you're trying to reference in the merge. If you're merging from one branch to another, then it seems like you'll need a non-default refspec, since you'll need both the source branch and the destination branch in the workspace.

          Christian Beikov added a comment - - edited

          I might as well have a wrong configuration, but then I don't understand why it works when executed on the master but not on the slave.

          The exception seems to be thrown because it tries to checkout the merged version i.e. the merge commit but that isn't created on the slave.

          I also find it a bit strange that when the master does the build, the repository is checked out into the workspace, whereas the slave doesn't do that.

          I'm using a configuration like the following. Maybe you see an error there?

           

          Repository 1

          Name: origin

          Refspec: +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*

           

          Repository 2

          Name: ${gitlabSourceRepoName}

          Refspec:

           

          Braches to build

          merge-requests/${gitlabMergeRequestId}

          origin/${gitlabSourceBranch}

           

          Merge before build

          Name of repository: origin

          Branch to merge to: ${gitlabTargetBranch}

          Merge strategy: default

          Fast-forward mode: --ff

          Christian Beikov added a comment - - edited I might as well have a wrong configuration, but then I don't understand why it works when executed on the master but not on the slave. The exception seems to be thrown because it tries to checkout the  merged version i.e. the  merge commit but that isn't created on the slave. I also find it a bit strange that when the master does the build, the repository is checked out into the workspace, whereas the slave doesn't do that. I'm using a configuration like the following. Maybe you see an error there?   Repository 1 Name: origin Refspec: +refs/heads/* :refs/remotes/origin/ * +refs/merge-requests/* /head:refs/remotes/origin/merge-requests/ *   Repository 2 Name: ${gitlabSourceRepoName} Refspec:   Braches to build merge-requests/${gitlabMergeRequestId} origin/${gitlabSourceBranch}   Merge before build Name of repository: origin Branch to merge to: ${gitlabTargetBranch} Merge strategy: default Fast-forward mode: --ff

          We are also experiencing this issue for many years now. We have two projects that depend on each other. So sometimes we do push the dependent project before the dependency project. In that case the merge would happen merging the new branch and creating a merge commit that doesn't exist anywhere else. When the dependency project completes the next build of the dependent would lead to this error.

          The only solution is to delete the failed build and the one before it then it would build again. 

          Samuel Gabriel added a comment - We are also experiencing this issue for many years now. We have two projects that depend on each other. So sometimes we do push the dependent project before the dependency project. In that case the merge would happen merging the new branch and creating a merge commit that doesn't exist anywhere else. When the dependency project completes the next build of the dependent would lead to this error. The only solution is to delete the failed build and the one before it then it would build again. 

            Unassigned Unassigned
            cbeikov Christian Beikov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: