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

file permissions aren't protected after archive/unarchive

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • pipeline
    • None

      If file has executable bit set and is archived then after unarchiving the executable bit is missing.

      Example flow:

      node {
        sh "touch test.sh && chmod 0755 test.sh"
        sh "ls -l test.sh"
        archive "test.sh"
        unarchive mapping: ["test.sh": "restore.sh"]
        sh "ls -lR"
      }
      

      Output:

      Started by user Timur
      Running: Allocate node : Start
      Running on master in /mnt1/jenkins/jobs/test-flow/workspace
      Running: Allocate node : Body : Start
      Running: Shell Script
      [workspace] Running shell script
      + touch test.sh
      + chmod 0755 test.sh
      Running: Shell Script
      [workspace] Running shell script
      + ls -l test.sh
      -rwxr-xr-x 1 jenkins jenkins 0 Jan 28 09:34 test.sh
      Running: Archive Artifacts
      Running: Copy archived artifacts into the workspace
      Running: Shell Script
      [workspace] Running shell script
      + ls -lR
      .:
      total 0
      -rw-r--r-- 1 jenkins jenkins 0 Jan 28 09:34 restore.sh
      -rwxr-xr-x 1 jenkins jenkins 0 Jan 28 09:34 test.sh
      Running: Allocate node : Body : End
      Running: Allocate node : End
      Running: End of Workflow
      Finished: SUCCESS
      

      It probably relates to some other plugin but not to workflow-plugin but I don't know how to create reproduceable case without using workflow-plugin.

          [JENKINS-26659] file permissions aren't protected after archive/unarchive

          Jesse Glick added a comment -

          I think this belongs here. UnarchiveStep is rather simplistic and makes no attempt to handle file permissions, symlinks, or any other subtleties.

          Jesse Glick added a comment - I think this belongs here. UnarchiveStep is rather simplistic and makes no attempt to handle file permissions, symlinks, or any other subtleties.

          Daniel Beck added a comment -

          Assuming workflow archives on the master (like regular Archive Artifacts) I wouldn't rely on this anyway – might be a Windows machine which would lose that information anyway.

          Daniel Beck added a comment - Assuming workflow archives on the master (like regular Archive Artifacts) I wouldn't rely on this anyway – might be a Windows machine which would lose that information anyway.

          Jesse Glick added a comment -

          Yes, of course it is best to avoid relying on it (and for example tar up any files locally whose exact permissions you want to preserve), but insofar as the archive step (using StandardArtifactManager) preserves permissions and symlinks, unarchive should as well.

          Jesse Glick added a comment - Yes, of course it is best to avoid relying on it (and for example tar up any files locally whose exact permissions you want to preserve), but insofar as the archive step (using StandardArtifactManager ) preserves permissions and symlinks, unarchive should as well.

          Jesse Glick added a comment -

          unarchive has been deprecated in 1.10 in favor of stash/unstash, which internally use a .tar.gz file that ought to preserve file atttributes.

          Jesse Glick added a comment - unarchive has been deprecated in 1.10 in favor of stash / unstash , which internally use a .tar.gz file that ought to preserve file atttributes.

          Bastien Arata added a comment - - edited

          stash/unstash has the same issue

          Bastien Arata added a comment - - edited stash/unstash has the same issue

          Nenad Miksa added a comment -

          The same issue happens with stash/unstash with Jenkins 2.140 and Pipeline 2.5

          Nenad Miksa added a comment - The same issue happens with stash/unstash with Jenkins 2.140 and Pipeline 2.5

          Daniel Beck added a comment -

          It's not the same issue if it affects completely different commands.

          Please file a new issue.

          Daniel Beck added a comment - It's not the same issue if it affects completely different commands. Please file a new issue.

          Nenad Miksa added a comment -

          I've reported it here: https://issues.jenkins-ci.org/browse/JENKINS-53374

          You were correct - it was not the same issue, I just observed the same result on my system, but after creating the minimal reproducing sample, I've seen that it's actually a completely different feature.

          Nenad Miksa added a comment - I've reported it here: https://issues.jenkins-ci.org/browse/JENKINS-53374 You were correct - it was not the  same issue, I just observed the same result on my system, but after creating the minimal reproducing sample, I've seen that it's actually a completely different feature.

            jglick Jesse Glick
            erthad Timur Batyrshin
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: