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

archiveArtifacts step failure is not displayed


    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • Jenkins 2.78
      Pipeline job

      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.

          stage('Failing Archive'){
                  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.

            jglick Jesse Glick
            wright L Wright
            0 Vote for this issue
            6 Start watching this issue