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

Git fetch in a later Pipeline stage fails when master received new revisions in the meantime

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • git-plugin, pipeline
    • None
    • This _seems_ independent of configuration specifics, so please let me know what you need before I perform the marathon and involve our admins.

      Here is a timeline of events.

      1. Revision 08979f16 on branch master pushed.
      2. Revision 29f59aa1 on branch hsp-2917 pushed.
      3. Multi-branch pipeline starts build for hsp-2917 as expected:
        Cloning the remote Git repository
        Cloning with configured refspecs honoured and without tags
        Cloning repository <redacted>
         > git init /build/workspace/<redacted>_hsp-2917 # timeout=10
        Fetching upstream changes from <redacted>
         > git --version # timeout=10
        using GIT_SSH to set credentials 
         > git fetch --no-tags --progress <redacted> +refs/heads/*:refs/remotes/origin/*
        Fetching without tags
        Checking out Revision 29f59aa14a5f70d2977315e4ec18d7fa6ed5dc34 (hsp-2917)
         > git config remote.origin.url <redacted> # timeout=10
         > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
         > git config remote.origin.url <redacted> # timeout=10
        Fetching upstream changes from <redacted>
        using GIT_SSH to set credentials 
         > git fetch --no-tags --progress <redacted> +refs/heads/*:refs/remotes/origin/*
         > git config core.sparsecheckout # timeout=10
         > git checkout -f 29f59aa14a5f70d2977315e4ec18d7fa6ed5dc34
        First time build. Skipping changelog.

        The build runs as per usual.

      4. New revisions 1c65836c and 54154615 are pushed to branch master.

      Expected: The build started in 3. is not affected by 4.

      Actual: A later stage (after length test stages) running on a different agent fails:

       > git fetch --no-tags --progress <redacted> +refs/heads/*:refs/remotes/origin/*
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from <redacted>
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:120)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:90)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:77)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress <redacted> +refs/heads/*:refs/remotes/origin/*" returned status code 1:
      stdout: 
      stderr: error: cannot lock ref 'refs/remotes/origin/master': ref refs/remotes/origin/master is at 54154615eb893f5f4f5e51107afd5aac296405af but expected 08979f16cf724f022852eeba8bbd8b3fad599cad
      From <redacted>
       ! 08979f1..5415461  master     -> origin/master  (unable to update local ref)
      

      We already know which we revision we want and should just check out that one. Newer revisions should not interfere with the build, no matter which branch they are on.
      (This didn't happen here, but the branch may even have been deleted, in which case the build should still work, assuming the revision under build is still there.)

            Unassigned Unassigned
            reitzig Raphael Reitzig
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: