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

DirectoryNotEmptyException when cleaning up after withCredentials/ZipFileBinding

    Details

    • Similar Issues:

      Description

      • Jenkins 1.633
      • credentials binding 1.5
      • credentials 1.24
      • workflow 1.10

      steps to reproduce

      1. upload a zip file to credentials as a secret file give it an ID of "myzip"
      2. create a workflow that references the above secret file
        node() {
              withCredentials([[$class: 'ZipFileBinding', credentialsId: 'myzip', variable: 'credentialsLocation']]) {
                sh 'THIS_SHOULD_FAIL_THE_BUILD'
              }
        }
        
      3. run the workflow

      expected results

      the workflow complets

      actual results

      the workflow fails with an exception removing the secret files (full stack in attached file)

      java.io.IOException: remote file operation failed: /scratch/jenkins/secretFiles/ed503d92-4726-4033-9afe-00affd88bde6 at hudson.remoting.Channel@25888a1:c1617b93: java.nio.file.DirectoryNotEmptyException: /scratch/jenkins/secretFiles/ed503d92-4726-4033-9afe-00affd88bde6/credentials.zip
      	at hudson.FilePath.act(FilePath.java:985)
      	at hudson.FilePath.act(FilePath.java:967)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1169)
      	at org.jenkinsci.plugins.credentialsbinding.impl.FileBinding$UnbinderImpl.unbind(FileBinding.java:76)
      	at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Callback.cleanup(BindingStep.java:176)
      	at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Callback.onFailure(BindingStep.java:189)
      	at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$FailureAdapter.receive(CpsBodyExecution.java:294)
      	at com.cloudbees.groovy.cps.impl.ThrowBlock$1.receive(ThrowBlock.java:68)
      Caused by: java.nio.file.DirectoryNotEmptyException: /scratch/jenkins/secretFiles/ed503d92-4726-4033-9afe-00affd88bde6/credentials.zip
      	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
      	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
      	at java.nio.file.Files.delete(Files.java:1079)
      

        Attachments

          Issue Links

            Activity

            Hide
            teilo James Nord added a comment - - edited

            Note: I was unable to reproduce this on a windows master with no slaves, but when adding a Linux slave and running the script on the slave this becomes reproducible.
            Not sure if this is due to the fact that it is running on a slave or that it is running on Linux (or both)

            Show
            teilo James Nord added a comment - - edited Note: I was unable to reproduce this on a windows master with no slaves, but when adding a Linux slave and running the script on the slave this becomes reproducible. Not sure if this is due to the fact that it is running on a slave or that it is running on Linux (or both)
            Hide
            jglick Jesse Glick added a comment -

            Presumably the chmod is ignored on Windows.

            Show
            jglick Jesse Glick added a comment - Presumably the chmod is ignored on Windows.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: James Nord
            Path:
            pom.xml
            src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java
            http://jenkins-ci.org/commit/credentials-binding-plugin/177dbd18230dd7df269f5a1c6e94463afdc039e7
            Log:
            JENKINS-30941 Unit test for failure of ZipFileBinding on Linux.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: pom.xml src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java http://jenkins-ci.org/commit/credentials-binding-plugin/177dbd18230dd7df269f5a1c6e94463afdc039e7 Log: JENKINS-30941 Unit test for failure of ZipFileBinding on Linux.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: James Nord
            Path:
            src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java
            http://jenkins-ci.org/commit/credentials-binding-plugin/3cd54c0a07fcc36ded63a39a2455f1d7337a8934
            Log:
            [FIXED JENKINS-30941] Do not remove execute and write bit from directories that need to be cleaned up

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java http://jenkins-ci.org/commit/credentials-binding-plugin/3cd54c0a07fcc36ded63a39a2455f1d7337a8934 Log: [FIXED JENKINS-30941] Do not remove execute and write bit from directories that need to be cleaned up
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: James Nord
            Path:
            src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java
            src/test/resources/org/jenkinsci/plugins/credentialsbinding/impl/a.zip
            http://jenkins-ci.org/commit/credentials-binding-plugin/2c5dca6e66e6e8b2c4116b1c0a337b604910c72b
            Log:
            JENKINS-30941 update test following feedback.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: James Nord Path: src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java src/test/resources/org/jenkinsci/plugins/credentialsbinding/impl/a.zip http://jenkins-ci.org/commit/credentials-binding-plugin/2c5dca6e66e6e8b2c4116b1c0a337b604910c72b Log: JENKINS-30941 update test following feedback.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java
            src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java
            src/test/resources/org/jenkinsci/plugins/credentialsbinding/impl/a.zip
            http://jenkins-ci.org/commit/credentials-binding-plugin/fdd7b1f5873bb0cf0d92695212a6fb6657e3014f
            Log:
            Merge pull request #10 from jtnord/JENKINS-30941

            [FIXED JENKINS-30941] do not set directories to 0400 on unix if you want to delete their contents...

            Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/ce0ade5b71cf...fdd7b1f5873b

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/ZipFileBindingTest.java src/test/resources/org/jenkinsci/plugins/credentialsbinding/impl/a.zip http://jenkins-ci.org/commit/credentials-binding-plugin/fdd7b1f5873bb0cf0d92695212a6fb6657e3014f Log: Merge pull request #10 from jtnord/ JENKINS-30941 [FIXED JENKINS-30941] do not set directories to 0400 on unix if you want to delete their contents... Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/ce0ade5b71cf...fdd7b1f5873b

              People

              • Assignee:
                teilo James Nord
                Reporter:
                teilo James Nord
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: