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

InvocationTargetException instead of AbortException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • workflow-baisc-step: 2.21 version
      copyartifact: 1.45.1 version

      Since 2.21 version of workflow-basic-steps plugin we've seen  the next problem.

       

      Working with the next test pipeline and using copyArtifact, when the target  project doesn't exist (for example), our catch should take care of it.

       

      In fact it always threw an AbortException.

       

       

      // pipeline {
          agent none    stages {
              stage ("Stage1") {
                  agent any 
                  steps{
                      script {                    try{
                              echo "Collecting artifacts from job." 
                              copyArtifacts filter: "file", fingerprintArtifacts: true, projectName: "NOTEXIST", selector: lastSuccessful(), target: "WHATEVER"
                          }catch(hudson.AbortException e){
                              print e
                              echo "Job  not found, launching build." 
                          }/*catch(Exception e){
                              print e
                          }*/                    echo 'Otra cosa'
                      }
                  }
              }
              stage ("Stage2") {
                  agent any 
                  steps{
                      script {
                          echo "More things" 
                      }
                  }
              }
          }
      }
      

       

      But now we get an InvocationTargetException and the catch code is never run as seen in the next log:

       

      Running on Jenkins in /var/jenkins_home/workspace/test
      [Pipeline] {
      [Pipeline] script
      [Pipeline] {
      [Pipeline] echo
      Collecting artifacts from job.
      [Pipeline] copyArtifacts
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Stage2)
      Stage "Stage2" skipped due to earlier failure(s)
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      hudson.AbortException: Unable to find project for artifact copy: NOTEXIST
      This may be due to incorrect project name or permission settings; see help for project name in job configuration.
      	at hudson.plugins.copyartifact.CopyArtifact.perform(CopyArtifact.java:452)
      	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:112)
      Caused: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:92)
      	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:70)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	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:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

      Using again 2.20 version of the plugin fixes the issue.

      We can see there's been changes related to CoreStep.java:

       

      https://github.com/jenkinsci/workflow-basic-steps-plugin/compare/workflow-basic-steps-2.20...workflow-basic-steps-2.21?short_path=4ac32a7#diff-4ac32a78649ca5bdd8e0ba38b7006a1e

       

       

      Thanks!

       

            jglick Jesse Glick
            ialbors Ignacio Albors
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: