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

archiveArtifacts step failure is not displayed

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
    • Environment:
      Jenkins 2.78
      Pipeline job
    • Similar Issues:

      Description

      If I surround a General build step (as described in the snippet generator)  in a try-catch block, within a scripted Jenkins file, the error is not caught.

      for example I expected the following code block to mark the build as unstable. But an error is thrown at the archiveArtifacts step.

      node(){
          stage('Failing Archive'){
              try{
                  archiveArtifacts 'non existent path'
              }
              catch (err)
              {
                  echo 'Archive failed!'
                  currentBuild.result = 'UNSTABLE'
              }
          }
      }
      

       
      EDIT (abayer): More generally - CoreStep executions of a SimpleBuildStep (such as archiveArtifacts, which is actually calling the ArtifactArchiver publisher from core), only throw an exception if the SimpleBuildStep itself throws an exception. And as a general rule, failure-but-not-error cases (like the non-existent path case here) of a SimpleBuildStep don't throw an exception, since the FreeStyleBuild they were initially used in would proceed anyway (especially in the case of publishers/recorders, which are the most common SimpleBuildStep implementations), after having set the build status.

        Attachments

          Issue Links

            Activity

            wright L Wright created issue -
            danielbeck Daniel Beck made changes -
            Field Original Value New Value
            Component/s core [ 15593 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-44407 [ JENKINS-44407 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-basic-steps-plugin [ 21712 ]
            Component/s pipeline [ 21692 ]
            abayer Andrew Bayer made changes -
            Summary Try-catch doesn't catch errors from general build steps CoreStep execution of SimpleBuildSteps doesn't actually fail in Pipeline
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Description If I surround a General build step (as described in the snippet generator)  in a try-catch block, within a scripted Jenkins file, the error is not caught.

            for example I expected the following code block to mark the build as unstable. But an error is thrown at the archiveArtifacts step.
            {code:java}
            node(){
                stage('Failing Archive'){
                    try{
                        archiveArtifacts 'non existent path'
                    }
                    catch (err)
                    {
                        echo 'Archive failed!'
                        currentBuild.result = 'UNSTABLE'
                    }
                }
            }
            {code}
             
            If I surround a General build step (as described in the snippet generator)  in a try-catch block, within a scripted Jenkins file, the error is not caught.

            for example I expected the following code block to mark the build as unstable. But an error is thrown at the archiveArtifacts step.
            {code:java}
            node(){
                stage('Failing Archive'){
                    try{
                        archiveArtifacts 'non existent path'
                    }
                    catch (err)
                    {
                        echo 'Archive failed!'
                        currentBuild.result = 'UNSTABLE'
                    }
                }
            }
            {code}
             
            EDIT (abayer): More generally - {{CoreStep}} executions of a {{SimpleBuildStep}} (such as {{archiveArtifacts}}, which is actually calling the {{ArtifactArchiver}} publisher from core), only throw an exception if the {{SimpleBuildStep}} itself throws an exception. And as a general rule, failure-but-not-error cases (like the non-existent path case here) of a {{SimpleBuildStep}} don't throw an exception, since the {{FreeStyleBuild}} they were initially used in would proceed anyway (especially in the case of publishers/recorders, which are the most common {{SimpleBuildStep}} implementations), after having set the build status.
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-31931 [ JENKINS-31931 ]
            jglick Jesse Glick made changes -
            Component/s core [ 15593 ]
            Component/s workflow-basic-steps-plugin [ 21712 ]
            jglick Jesse Glick made changes -
            Assignee Andrew Bayer [ abayer ] Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Summary CoreStep execution of SimpleBuildSteps doesn't actually fail in Pipeline archiveArtifacts step failure is not displayed
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 3265 (Web Link)" [ 19955 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            danielbeck Daniel Beck made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-45200 [ JENKINS-45200 ]
            pholden Paul Holden made changes -
            Link This issue is related to JENKINS-51913 [ JENKINS-51913 ]

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                wright L Wright
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: