• 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

          Pinned comments

          Pinned by Aleksei

          ivdok . added a comment -

          Issue still present as of 2.303.1. We currently solved this by invoking:

          sh 'mkdir -p .git && chmod -R u+w .git'
          unstash "checkout"
          sh 'chmod -R u+rwx .git'
          

          ivdok . added a comment - Issue still present as of 2.303.1. We currently solved this by invoking: sh 'mkdir -p .git && chmod -R u+w .git' unstash "checkout" sh 'chmod -R u+rwx .git'

          All comments

          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

          ipleten added a comment -

          We also faced that issue.

          ipleten added a comment - We also faced that issue.

          faced into the same problem

          Mykhailo Zolotarenko added a comment - faced into the same problem

          just a heads up to everybody who encounters this issue, please vote for this issue so that it gets attention, to vote for it click on Vote on the top right of this page

          Alan Czajkowski added a comment - just a heads up to everybody who encounters this issue, please vote for this issue so that it gets attention, to vote for it click on Vote on the top right of this page

          Pablo Chacin added a comment -

          Also facing this issue when unstashing a read-only file

          Pablo Chacin added a comment - Also facing this issue when unstashing a read-only file

          Micah Snyder added a comment - - edited

          I ran into this issue as well. Using the `chmod` trick on the directory I was about to stash before stashing seems to have resolved the issue for me.

          Edit: nevermind, this step is still flaking out for me. Completely stumped as to why it worked a moment ago.

          Micah Snyder added a comment - - edited I ran into this issue as well. Using the `chmod` trick on the directory I was about to stash before stashing seems to have resolved the issue for me. Edit: nevermind, this step is still flaking out for me. Completely stumped as to why it worked a moment ago.

          Pinned by Aleksei

          ivdok . added a comment -

          Issue still present as of 2.303.1. We currently solved this by invoking:

          sh 'mkdir -p .git && chmod -R u+w .git'
          unstash "checkout"
          sh 'chmod -R u+rwx .git'
          

          ivdok . added a comment - Issue still present as of 2.303.1. We currently solved this by invoking: sh 'mkdir -p .git && chmod -R u+w .git' unstash "checkout" sh 'chmod -R u+rwx .git'

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

              Created:
              Updated: