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

archive step sets result to FAILURE but does not fail the job

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • core
    • Jenkins 1.625.2 LTS

      When no files matching the file mask are found, the archive workflow step as well as the general build step will set the result of the workflow to FAILURE but the build continues. The Step is not marked as failed in the "Workflow Steps" graph

      node('master') {
        archive "nonexistingdir/"
        step([$class: 'ArtifactArchiver', artifacts: 'nonexistingdir/', excludes: null])
      }
      

      Both steps are marked as SUCCESS, the overall build is marked as FAILED, though. There is no (error) message.

          [JENKINS-31931] archive step sets result to FAILURE but does not fail the job

          Jesse Glick added a comment -

          The now-deprecated archive step does not fail the build.

          ArtifactArchiver in core does fail the build unless you pass allowEmptyArchive: true. However its result != null && result.isBetterOrEqualTo(Result.UNSTABLE) condition ought to read result == null || result.isBetterOrEqualTo(Result.UNSTABLE) since for a Pipeline build normally the result is null until the end of the build.

          Also rather than calling build.setResult(Result.FAILURE), it should throw an AbortException. Similarly, the whole try-catch block could better be deleted.

          Jesse Glick added a comment - The now-deprecated archive step does not fail the build. ArtifactArchiver in core does fail the build unless you pass allowEmptyArchive: true . However its result != null && result.isBetterOrEqualTo(Result.UNSTABLE) condition ought to read result == null || result.isBetterOrEqualTo(Result.UNSTABLE) since for a Pipeline build normally the result is null until the end of the build. Also rather than calling build.setResult(Result.FAILURE) , it should throw an AbortException . Similarly, the whole try - catch block could better be deleted.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepExecution.java
          src/main/java/org/jenkinsci/plugins/workflow/steps/CoreStep.java
          src/test/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepTest.java
          src/test/java/org/jenkinsci/plugins/workflow/steps/CoreStepTest.java
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/be563c856a50995271be490911988be0996865c4
          Log:
          Testing JENKINS-31931.
          Also fixing a buglet with nonexistent workspaces.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepExecution.java src/main/java/org/jenkinsci/plugins/workflow/steps/CoreStep.java src/test/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepTest.java src/test/java/org/jenkinsci/plugins/workflow/steps/CoreStepTest.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/be563c856a50995271be490911988be0996865c4 Log: Testing JENKINS-31931 . Also fixing a buglet with nonexistent workspaces.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepExecution.java
          src/main/java/org/jenkinsci/plugins/workflow/steps/CoreStep.java
          src/test/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepTest.java
          src/test/java/org/jenkinsci/plugins/workflow/steps/CoreStepTest.java
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/05bf1fb6446d37ef8634555e1e1c8bb331cdf9ac
          Log:
          Merge pull request #17 from jglick/test-JENKINS-31931

          JENKINS-31931 Adding test case

          Compare: https://github.com/jenkinsci/workflow-basic-steps-plugin/compare/86af7fdf73cd...05bf1fb6446d

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepExecution.java src/main/java/org/jenkinsci/plugins/workflow/steps/CoreStep.java src/test/java/org/jenkinsci/plugins/workflow/steps/ArtifactArchiverStepTest.java src/test/java/org/jenkinsci/plugins/workflow/steps/CoreStepTest.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/05bf1fb6446d37ef8634555e1e1c8bb331cdf9ac Log: Merge pull request #17 from jglick/test- JENKINS-31931 JENKINS-31931 Adding test case Compare: https://github.com/jenkinsci/workflow-basic-steps-plugin/compare/86af7fdf73cd...05bf1fb6446d

          Jesse Glick added a comment -

          abayer fixed the main problem here in JENKINS-38005, though not the additional cleanup that I suggest.

          Jesse Glick added a comment - abayer fixed the main problem here in  JENKINS-38005 , though not the additional cleanup that I suggest.

            Unassigned Unassigned
            gordin Christoph VogtlÃĪnder
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: