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

clone-workspace-scm can get confused if it isn't the last thing on the post-build actions

    Details

    • Similar Issues:

      Description

      The build status that the "clone workspace" triggers on is not necessarily the same build status that gets recorded after all the remaining post-build-steps have run.
      This can mean that the clone-workspace-scm plugin looks in the wrong folder for the archive file.
      This also means that the plugin ends up leaving old archived workspaces on the machine.

      e.g. consider the following scenario:

      1. Project "Foo" defined as
        • Some build steps
        • Some post-build steps as follows:
          1. "Archive for clone workspace SCM" with a criteria of "most recent successful build"
          2. Publish JUnit test results, which can set the build result to "unstable" if any fail
      2. Project "Bar" defined as
        • SCM of cloned-workspace from build "Foo"
        • Some build & post-build steps

      And the following builds that happen

      1. Foo build#1 runs.
        • Build steps are ok (result=SUCCESS).
        • Post build:
          1. it archives the workspace (as result==SUCCESS)
          2. all unit tests pass (so result stays == SUCCESS)
          3. Jenkins reports build as SUCCESS
      2. Bar build#1 runs
        • it loads from Foo build#1 (as that's the most recent "success" build for Foo).
      3. Foo build#2 runs.
        • Build steps fail (result=FAILURE).
        • Post build:
          1. it does NOT archive the workspace (as result!=SUCCESS)
          2. no unit-tests ran (so result stays unchanged)
          3. Jenkins reports build as FAILURE
      4. Bar build#2 runs.
        • it loads from Foo build#1 (as that's the most recent "success" build for Foo).
      5. Foo build#3 runs.
        • Build steps are ok (result=SUCCESS).
        • Post build:
          1. it archives the workspace (as result==SUCCESS). This means that it also deletes the archived workspace from Foo build#1.
          2. some unit-tests failed (so result is then set to UNSTABLE).
          3. Jenkins reports the build as UNSTABLE.
      6. Bar build#3 runs.
        • it tries to load from Foo build#1 (as that's the most recent "success" build for Foo). It fails with a java.io.EOFException
      7. Foo build#4 runs.
        • Build steps are ok (result=SUCCESS).
        • Post build:
          1. it archives the workspace (as result==SUCCESS). It also tries to delete the previously-archived workspace, but it doesn't find it, so it leaves Foo build#3's archived workspace on the server.
          2. all unit tests pass (so result stays == SUCCESS)
          3. Jenkins reports build as SUCCESS

      Workaround:
      None of this ever happens if one always ensures that the build archive step is always the very last step.
      However, one often wants to trigger builds /after/ the archive stage, so it can't always be the last step.

        Attachments

          Activity

          pjdarton pjdarton created issue -
          Hide
          pjdarton pjdarton added a comment -

          I found this issue after one of my fellow devs came to me asking for help with a broken build.
          The exception they encountered was as follows:

          Started by upstream project "Foo" build number 3
          Building remotely on myslave in workspace C:\jenkins\workspace\Foo
          Restoring workspace from build #1 of project Foo
          hudson.util.IOException2: remote file operation failed: C:\jenkins\workspace\Foo at hudson.remoting.Channel@6fc1b36a:myslave
          at hudson.FilePath.act(FilePath.java:838)
          at hudson.FilePath.act(FilePath.java:824)
          at hudson.FilePath.untar(FilePath.java:466)
          at hudson.plugins.cloneworkspace.CloneWorkspacePublisher$WorkspaceSnapshotTar.restoreTo(CloneWorkspacePublisher.java:243)
          at hudson.plugins.cloneworkspace.CloneWorkspaceSCM$Snapshot.restoreTo(CloneWorkspaceSCM.java:383)
          at hudson.plugins.cloneworkspace.CloneWorkspaceSCM.checkout(CloneWorkspaceSCM.java:149)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
          at hudson.model.Run.execute(Run.java:1502)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:236)
          Caused by: hudson.util.IOException2: null
          stream=
          at hudson.FilePath$TarCompression$2.extract(FilePath.java:620)
          at hudson.FilePath$3.invoke(FilePath.java:468)
          at hudson.FilePath$3.invoke(FilePath.java:466)
          at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2236)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:287)
          at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
          at java.util.concurrent.FutureTask.run(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at hudson.remoting.Engine$1$1.run(Engine.java:60)
          at java.lang.Thread.run(Unknown Source)
          Caused by: java.io.EOFException
          at java.util.zip.GZIPInputStream.readUByte(Unknown Source)
          at java.util.zip.GZIPInputStream.readUShort(Unknown Source)
          at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
          at java.util.zip.GZIPInputStream.<init>(Unknown Source)
          at hudson.FilePath$TarCompression$2.extract(FilePath.java:616)
          ... 13 more

          Show
          pjdarton pjdarton added a comment - I found this issue after one of my fellow devs came to me asking for help with a broken build. The exception they encountered was as follows: Started by upstream project "Foo" build number 3 Building remotely on myslave in workspace C:\jenkins\workspace\Foo Restoring workspace from build #1 of project Foo hudson.util.IOException2: remote file operation failed: C:\jenkins\workspace\Foo at hudson.remoting.Channel@6fc1b36a:myslave at hudson.FilePath.act(FilePath.java:838) at hudson.FilePath.act(FilePath.java:824) at hudson.FilePath.untar(FilePath.java:466) at hudson.plugins.cloneworkspace.CloneWorkspacePublisher$WorkspaceSnapshotTar.restoreTo(CloneWorkspacePublisher.java:243) at hudson.plugins.cloneworkspace.CloneWorkspaceSCM$Snapshot.restoreTo(CloneWorkspaceSCM.java:383) at hudson.plugins.cloneworkspace.CloneWorkspaceSCM.checkout(CloneWorkspaceSCM.java:149) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run.java:1502) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236) Caused by: hudson.util.IOException2: null stream= at hudson.FilePath$TarCompression$2.extract(FilePath.java:620) at hudson.FilePath$3.invoke(FilePath.java:468) at hudson.FilePath$3.invoke(FilePath.java:466) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2236) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:287) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at hudson.remoting.Engine$1$1.run(Engine.java:60) at java.lang.Thread.run(Unknown Source) Caused by: java.io.EOFException at java.util.zip.GZIPInputStream.readUByte(Unknown Source) at java.util.zip.GZIPInputStream.readUShort(Unknown Source) at java.util.zip.GZIPInputStream.readHeader(Unknown Source) at java.util.zip.GZIPInputStream.<init>(Unknown Source) at hudson.FilePath$TarCompression$2.extract(FilePath.java:616) ... 13 more
          rtyler R. Tyler Croy made changes -
          Field Original Value New Value
          Workflow JNJira [ 151331 ] JNJira + In-Review [ 177921 ]

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              pjdarton pjdarton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: