• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-api-plugin
    • None

      We're using stash & unstash to pass a checked out git repository between steps in our workflow.
      On first run the unstash works successfully, however on a second run the unstash fails because some of the files in the `.git` directory are read-only.

      I've attached the stack trace, it's a bit misleading, we've fixed it by running a `sh 'chmod -R u+w .git'` before the unstash step.

          [JENKINS-33126] unstash fails to overwrite read-only files

          Marcus Cobden created issue -
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 168995 ] New: JNJira + In-Review [ 183314 ]
          Andrew Bayer made changes -
          Component/s New: pipeline-general [ 21692 ]
          Andrew Bayer made changes -
          Component/s Original: workflow-plugin [ 18820 ]
          Jesse Glick made changes -
          Component/s New: workflow-api-plugin [ 21711 ]
          Component/s Original: pipeline [ 21692 ]

          seems to happen on windows slaves too at least since the 2.56:

           

          java.io.IOException: remote file operation failed: D:\hf-sonar\ws\m-6WBYNI4TQ6 at hudson.remoting.Channel@dac5763:JNLP4-connect connection from ***: java.io.IOException: Failed to extract archive.tar.gz
              at hudson.FilePath.act(FilePath.java:993)
              at hudson.FilePath.act(FilePath.java:975)
              at hudson.FilePath.untar(FilePath.java:528)
              at org.jenkinsci.plugins.workflow.flow.StashManager.unstash(StashManager.java:122)
              at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:74)
              at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:61)
              at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:49)
              at hudson.security.ACL.impersonate(ACL.java:260)
              at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:46)
              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:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)
              Suppressed: hudson.AbortException: script returned exit code 143
                  at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.check(DurableTaskStep.java:319)
                  at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.run(DurableTaskStep.java:275)
                  at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
                  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
                  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
                  ... 3 more
          Caused by: java.io.IOException: Failed to extract archive.tar.gz
              at hudson.FilePath.readFromTar(FilePath.java:2297)
              at hudson.FilePath.access$400(FilePath.java:196)
              at hudson.FilePath$4.invoke(FilePath.java:530)
              at hudson.FilePath$4.invoke(FilePath.java:528)
              at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2739)
              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(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
              at hudson.remoting.Engine$1$1.run(Engine.java:94)
              at java.lang.Thread.run(Unknown Source)
              at ......remote call to JNLP4-connect connection from 192.168.51.90/192.168.51.90:49162(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.FilePath.act(FilePath.java:986)
              ... 13 more
          Caused by: java.nio.file.AccessDeniedException: D:\hf-sonar\ws\m-6WBYNI4TQ6******\.git\objects\pack\pack-45bb9a3aedb05943d3d3c792e02f5eb40b336269.idx
              at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
              at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
              at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
              at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
              at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
              at java.nio.file.Files.newOutputStream(Unknown Source)
              at hudson.util.IOUtils.copy(IOUtils.java:39)
              at hudson.FilePath.readFromTar(FilePath.java:2287)
              at hudson.FilePath.access$400(FilePath.java:196)
              at hudson.FilePath$4.invoke(FilePath.java:530)
              at hudson.FilePath$4.invoke(FilePath.java:528)
              at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2739)
              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(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
              at hudson.remoting.Engine$1$1.run(Engine.java:94)
              at java.lang.Thread.run(Unknown Source)
          {{    }}

          Florian Doersch added a comment - seems to happen on windows slaves too at least since the 2.56:   java.io.IOException: remote file operation failed: D:\hf-sonar\ws\m-6WBYNI4TQ6 at hudson.remoting.Channel@dac5763:JNLP4-connect connection from ***: java.io.IOException: Failed to extract archive.tar.gz     at hudson.FilePath.act(FilePath.java:993)     at hudson.FilePath.act(FilePath.java:975)     at hudson.FilePath.untar(FilePath.java:528)     at org.jenkinsci.plugins.workflow.flow.StashManager.unstash(StashManager.java:122)     at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:74)     at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:61)     at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:49)     at hudson.security.ACL.impersonate(ACL.java:260)     at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:46)     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:1142)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)     at java.lang.Thread.run(Thread.java:745)     Suppressed: hudson.AbortException: script returned exit code 143         at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.check(DurableTaskStep.java:319)         at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.run(DurableTaskStep.java:275)         at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)         ... 3 more Caused by: java.io.IOException: Failed to extract archive.tar.gz     at hudson.FilePath.readFromTar(FilePath.java:2297)     at hudson.FilePath.access$400(FilePath.java:196)     at hudson.FilePath$4.invoke(FilePath.java:530)     at hudson.FilePath$4.invoke(FilePath.java:528)     at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2739)     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(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)     at hudson.remoting.Engine$1$1.run(Engine.java:94)     at java.lang.Thread.run(Unknown Source)     at ......remote call to JNLP4-connect connection from 192.168.51.90/192.168.51.90:49162(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.FilePath.act(FilePath.java:986)     ... 13 more Caused by: java.nio.file.AccessDeniedException: D:\hf-sonar\ws\m-6WBYNI4TQ6******\.git\objects\pack\pack-45bb9a3aedb05943d3d3c792e02f5eb40b336269.idx     at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)     at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)     at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)     at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)     at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)     at java.nio.file.Files.newOutputStream(Unknown Source)     at hudson.util.IOUtils.copy(IOUtils.java:39)     at hudson.FilePath.readFromTar(FilePath.java:2287)     at hudson.FilePath.access$400(FilePath.java:196)     at hudson.FilePath$4.invoke(FilePath.java:530)     at hudson.FilePath$4.invoke(FilePath.java:528)     at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2739)     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(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)     at hudson.remoting.Engine$1$1.run(Engine.java:94)     at java.lang.Thread.run(Unknown Source) {{    }}

          Omit Rathore added a comment -

          Yes same issue I have also faced , recommend it to increase priority as some integration tools needs git meta

          Omit Rathore added a comment - Yes same issue I have also faced , recommend it to increase priority as some integration tools needs git meta

          adam adam added a comment -

          I face the same issue. Unfortunately workaround using chmod i snot working for me.
          Please increase the issue priority as it  significantly affects pipelines performance - instead of reusing existing artifacts every stage requires rebuilding them.

          adam adam added a comment - I face the same issue. Unfortunately workaround using chmod i snot working for me. Please increase the issue priority as it  significantly affects pipelines performance - instead of reusing existing artifacts every stage requires rebuilding them.

          What is the status of the ticket? We have the same problem.

          Christian Kipping added a comment - What is the status of the ticket? We have the same problem.

          Alan Czajkowski added a comment - - edited

          running into the same problem, being able to unstash the .git/ directory is very important for certain tools and needs to be allowed when moving the workspace around

          Jenkinsfile:

          ...
            stash name: WORKSPACE_NAME, useDefaultExcludes: false
          ...
            unstash name: WORKSPACE_NAME
          ...
          

          references:

          Alan Czajkowski added a comment - - edited running into the same problem, being able to unstash the .git/ directory is very important for certain tools and needs to be allowed when moving the workspace around Jenkinsfile : ... stash name: WORKSPACE_NAME, useDefaultExcludes: false ... unstash name: WORKSPACE_NAME ... references: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#stash-stash-some-files-to-be-used-later-in-the-build useDefaultExcludes (optional) If selected, use the default excludes from Ant - see here for the list. Type: boolean

            jglick Jesse Glick
            mcobden Marcus Cobden
            Votes:
            32 Vote for this issue
            Watchers:
            27 Start watching this issue

              Created:
              Updated: