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

archiveArtifacts step failure is not displayed

    XMLWordPrintable

    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

            Hide
            danielbeck Daniel Beck added a comment -

            This is log output, not an exception. What is this issue about?

            Show
            danielbeck Daniel Beck added a comment - This is log output, not an exception. What is this issue about?
            Hide
            wright L Wright added a comment -

            I would expect the try-catch block to catch the archiveArtifact error, and follow through on the catch clause. As a result the build status should unstable not failure.

            Show
            wright L Wright added a comment - I would expect the try-catch block to catch the archiveArtifact error, and follow through on the catch clause. As a result the build status should unstable not failure.
            Hide
            abayer Andrew Bayer added a comment -

            I've refined the description a bit (as well as the summary) - JENKINS-44407 is another symptom of the same underlying problem: CoreStep only throws an exception (and marks its FlowNode as failed) if the SimpleBuildStep throws an exception, but as a general rule, a SimpleBuildStep won't throw an exception unless something goes very wrong.

            I'm not sure there's much we can do about this, but I'll leave it open and assigned to me for future pondering.

            Show
            abayer Andrew Bayer added a comment - I've refined the description a bit (as well as the summary) - JENKINS-44407 is another symptom of the same underlying problem: CoreStep only throws an exception (and marks its FlowNode as failed) if the SimpleBuildStep throws an exception, but as a general rule, a SimpleBuildStep won't throw an exception unless something goes very wrong. I'm not sure there's much we can do about this, but I'll leave it open and assigned to me for future pondering.
            Hide
            jglick Jesse Glick added a comment -

            Andrew Bayer I do not see any problem here. SimpleBuildStep.perform deliberately removed the boolean return value as a reminder that implementations are expected to throw AbortException in case of a normal user error. If ArtifactArchiver fails to throw AbortException, that is a core bug—fix it. In fact I said exactly that months ago, in JENKINS-31931.

            Show
            jglick Jesse Glick added a comment - Andrew Bayer I do not see any problem here. SimpleBuildStep.perform deliberately removed the boolean return value as a reminder that implementations are expected to throw AbortException in case of a normal user error. If ArtifactArchiver fails to throw AbortException , that is a core bug—fix it. In fact I said exactly that months ago, in  JENKINS-31931 .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/FilePath.java
            core/src/main/java/hudson/tasks/ArtifactArchiver.java
            core/src/main/resources/hudson/tasks/Messages.properties
            core/src/main/resources/hudson/tasks/Messages_bg.properties
            core/src/main/resources/hudson/tasks/Messages_da.properties
            core/src/main/resources/hudson/tasks/Messages_de.properties
            core/src/main/resources/hudson/tasks/Messages_es.properties
            core/src/main/resources/hudson/tasks/Messages_fr.properties
            core/src/main/resources/hudson/tasks/Messages_it.properties
            core/src/main/resources/hudson/tasks/Messages_ja.properties
            core/src/main/resources/hudson/tasks/Messages_nl.properties
            core/src/main/resources/hudson/tasks/Messages_pt_BR.properties
            core/src/main/resources/hudson/tasks/Messages_ru.properties
            core/src/main/resources/hudson/tasks/Messages_sr.properties
            core/src/main/resources/hudson/tasks/Messages_tr.properties
            core/src/main/resources/hudson/tasks/Messages_zh_TW.properties
            http://jenkins-ci.org/commit/jenkins/193855d1fb82e980e93f0c9ce3c15c459d448fab
            Log:
            JENKINS-47142 Simplifying the logic of ArtifactArchiver.perform, making it friendlier to Pipeline.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/FilePath.java core/src/main/java/hudson/tasks/ArtifactArchiver.java core/src/main/resources/hudson/tasks/Messages.properties core/src/main/resources/hudson/tasks/Messages_bg.properties core/src/main/resources/hudson/tasks/Messages_da.properties core/src/main/resources/hudson/tasks/Messages_de.properties core/src/main/resources/hudson/tasks/Messages_es.properties core/src/main/resources/hudson/tasks/Messages_fr.properties core/src/main/resources/hudson/tasks/Messages_it.properties core/src/main/resources/hudson/tasks/Messages_ja.properties core/src/main/resources/hudson/tasks/Messages_nl.properties core/src/main/resources/hudson/tasks/Messages_pt_BR.properties core/src/main/resources/hudson/tasks/Messages_ru.properties core/src/main/resources/hudson/tasks/Messages_sr.properties core/src/main/resources/hudson/tasks/Messages_tr.properties core/src/main/resources/hudson/tasks/Messages_zh_TW.properties http://jenkins-ci.org/commit/jenkins/193855d1fb82e980e93f0c9ce3c15c459d448fab Log: JENKINS-47142 Simplifying the logic of ArtifactArchiver.perform, making it friendlier to Pipeline.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oleg Nenashev
            Path:
            core/src/main/java/hudson/FilePath.java
            core/src/main/java/hudson/tasks/ArtifactArchiver.java
            core/src/main/resources/hudson/tasks/Messages.properties
            core/src/main/resources/hudson/tasks/Messages_bg.properties
            core/src/main/resources/hudson/tasks/Messages_da.properties
            core/src/main/resources/hudson/tasks/Messages_de.properties
            core/src/main/resources/hudson/tasks/Messages_es.properties
            core/src/main/resources/hudson/tasks/Messages_fr.properties
            core/src/main/resources/hudson/tasks/Messages_it.properties
            core/src/main/resources/hudson/tasks/Messages_ja.properties
            core/src/main/resources/hudson/tasks/Messages_nl.properties
            core/src/main/resources/hudson/tasks/Messages_pt_BR.properties
            core/src/main/resources/hudson/tasks/Messages_ru.properties
            core/src/main/resources/hudson/tasks/Messages_sr.properties
            core/src/main/resources/hudson/tasks/Messages_tr.properties
            core/src/main/resources/hudson/tasks/Messages_zh_TW.properties
            http://jenkins-ci.org/commit/jenkins/e5fd7b7c90077e681454723bb952acc7067e4443
            Log:
            Merge pull request #3265 from jglick/simple-build-steps-should-be-simple-JENKINS-47142

            JENKINS-47142 Simplifying the logic of ArtifactArchiver.perform, making it friendlier to Pipeline

            Compare: https://github.com/jenkinsci/jenkins/compare/b4dc44806119...e5fd7b7c9007

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/FilePath.java core/src/main/java/hudson/tasks/ArtifactArchiver.java core/src/main/resources/hudson/tasks/Messages.properties core/src/main/resources/hudson/tasks/Messages_bg.properties core/src/main/resources/hudson/tasks/Messages_da.properties core/src/main/resources/hudson/tasks/Messages_de.properties core/src/main/resources/hudson/tasks/Messages_es.properties core/src/main/resources/hudson/tasks/Messages_fr.properties core/src/main/resources/hudson/tasks/Messages_it.properties core/src/main/resources/hudson/tasks/Messages_ja.properties core/src/main/resources/hudson/tasks/Messages_nl.properties core/src/main/resources/hudson/tasks/Messages_pt_BR.properties core/src/main/resources/hudson/tasks/Messages_ru.properties core/src/main/resources/hudson/tasks/Messages_sr.properties core/src/main/resources/hudson/tasks/Messages_tr.properties core/src/main/resources/hudson/tasks/Messages_zh_TW.properties http://jenkins-ci.org/commit/jenkins/e5fd7b7c90077e681454723bb952acc7067e4443 Log: Merge pull request #3265 from jglick/simple-build-steps-should-be-simple- JENKINS-47142 JENKINS-47142 Simplifying the logic of ArtifactArchiver.perform, making it friendlier to Pipeline Compare: https://github.com/jenkinsci/jenkins/compare/b4dc44806119...e5fd7b7c9007
            Hide
            danielbeck Daniel Beck added a comment -

            Released in 2.108.

            Show
            danielbeck Daniel Beck added a comment - Released in 2.108.
            Hide
            pholden Paul Holden added a comment -

            The changes implemented in this task seem to be causing a full stacktrace to be printed to the build console in the case where there are no artifacts to archive (see JENKINS-51913) - is this intentional?

            Show
            pholden Paul Holden added a comment - The changes implemented in this task seem to be causing a full stacktrace to be printed to the build console in the case where there are no artifacts to archive (see  JENKINS-51913 ) - is this intentional?

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: