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

a failure in an exit of a step hides failures inside the step

    Details

    • Similar Issues:

      Description

      observed in the following script

      node() {
          withCredentials([[$class: 'ZipFileBinding', credentialsId: 'zip-credentials', variable: 'ZIP_LOC']]) {
            echo '1'
            withCredentials([[$class: 'FileBinding', credentialsId: 'ssh-key', variable: 'MY_SSH_KEY']]) {
              echo '2'
              sh 'echo Hello World - ${ZIP_LOC}  --- ${MY_SSH_KEY}'
            }
          }
      }
      

      there was an issue with the second withCredentials step but the workflow logs list the following

      Running: Bind credentials to variables : Start
      Running: Bind credentials to variables : Body : Start
      Running: Print Message
      1
      Running: Bind credentials to variables : Start
      Running: Bind credentials to variables : End
      Running: Bind credentials to variables : Body : End
      Running: Bind credentials to variables : End
      Running: Change Directory : Body : End
      Running: Change Directory : End
      Running: Allocate node : Body : End
      Running: Allocate node : End
      Running: End of Workflow
      java.io.IOException: remote file operation failed: /scratch/jenkins/secretFiles/8ae515c7-76d4-4021-aff3-233263e97a71 at hudson.remoting.Channel@76710f3e:400b174c: java.nio.file.DirectoryNotEmptyException: /scratch/jenkins/secretFiles/8ae515c7-76d4-4021-aff3-233263e97a71/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.ContinuationGroup.throwException(ContinuationGroup.java:203)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:75)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      	at sun.reflect.GeneratedMethodAccessor664.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:40)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:145)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:106)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:271)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:71)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:180)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:178)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.nio.file.DirectoryNotEmptyException: /scratch/jenkins/secretFiles/8ae515c7-76d4-4021-aff3-233263e97a71/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)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at hudson.Util.deleteFile(Util.java:247)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1202)
      	at hudson.FilePath.deleteContentsRecursive(FilePath.java:1211)
      	at hudson.FilePath.deleteRecursive(FilePath.java:1193)
      	at hudson.FilePath.access$1000(FilePath.java:191)
      	at hudson.FilePath$14.invoke(FilePath.java:1172)
      	at hudson.FilePath$14.invoke(FilePath.java:1169)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2688)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:121)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:49)
      	at hudson.remoting.Request$2.run(Request.java:325)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      	at ......remote call to 400b174c(Native Method)
      	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1360)
      	at hudson.remoting.UserResponse.retrieve(UserRequest.java:221)
      	at hudson.remoting.Channel.call(Channel.java:753)
      	at hudson.FilePath.act(FilePath.java:978)
      	... 36 more
      Finished: FAILURE
      

      Note that "2" is not printed, nor is the shell run - as the second credentials file failed - but there are no logs as to why.
      If the order of the 2 withCredentials steps is reveresed you see the true cause of the failure:

      java.io.IOException: remote file operation failed: /scratch/jenkins/secretFiles/35effc3c-7cfe-4d39-ad01-720f9f0c0913 at hudson.remoting.Channel@18993415:13ca24de: java.io.FileNotFoundException: /scratch/jenkins/secretFiles/35effc3c-7cfe-4d39-ad01-720f9f0c0913 (Is a directory)
      	at hudson.FilePath.act(FilePath.java:985)
      	at hudson.FilePath.act(FilePath.java:967)
      	at hudson.FilePath.write(FilePath.java:1881)
      	at hudson.FilePath.copyFrom(FilePath.java:882)
      	at org.jenkinsci.plugins.credentialsbinding.impl.FileBinding.copy(FileBinding.java:89)
      	at org.jenkinsci.plugins.credentialsbinding.impl.FileBinding.bindSingle(FileBinding.java:60)
      	at org.jenkinsci.plugins.credentialsbinding.Binding.bind(Binding.java:126)
      

        Attachments

          Activity

          Hide
          jglick Jesse Glick added a comment -

          I think the issue is that cleanup from onFailure needs to use Throwable.addSuppressed (Java 7+). In other WF steps this would be TailCall.finished (credentials-binding is not yet using that).

          Show
          jglick Jesse Glick added a comment - I think the issue is that cleanup from onFailure needs to use Throwable.addSuppressed (Java 7+). In other WF steps this would be TailCall.finished ( credentials-binding is not yet using that).
          Hide
          jglick Jesse Glick added a comment -

          workflow-step-api PR 5 fixed this in TailCall, so just need to use that from BindingStep.Callback.

          Show
          jglick Jesse Glick added a comment - workflow-step-api PR 5 fixed this in TailCall , so just need to use that from BindingStep.Callback .
          Hide
          jglick Jesse Glick added a comment -

          …which happened in PR 24.

          Show
          jglick Jesse Glick added a comment - …which happened in PR 24.

            People

            • Assignee:
              jglick Jesse Glick
              Reporter:
              teilo James Nord
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: