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

Crap4J does not correctly fail the build when reporting fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: crap4j-plugin
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      For more details see this thread:
      https://issues.jenkins-ci.org/browse/JENKINS-24833

      When Crap4J has a failure and can't find the report files, it returns false instead of setting build status to build.FAILURE. This results in Jenkins eventually recognizing a failed build, but allows all other post build steps to run including steps that are only supposed to run with a successful build. I think this should be a one line fix to add:
      build.setResult(Result.FAILURE);
      and then return true instead of false.

      Crap4J returns false on failure https://svn.jenkins-ci.org/trunk/hudson/plugins/crap4j/src/main/java/hudson/plugins/crap4j/Crap4JPublisher.java
      if (0 == reports.length)

      { log(logger, "No crap4j report files were found. Configuration error?"); return false; }

      Where xUnit returns true and sets the build result to failure
      https://github.com/jenkinsci/xunit-plugin/blob/a0ad57db81ef5a91162dbfa7190a1a8bcb838edd/src/main/java/org/jenkinsci/plugins/xunit/XUnitProcessor.java#L83

      GitPublisher is looking at the build result to determine a successful result or not:
      https://github.com/jenkinsci/git-plugin/blob/cebb9da131fa6c9e07ec9e6ff71ec89aa58fdd6f/src/main/java/hudson/plugins/git/GitPublisher.java#L203

      Theoretically the false result is canContinue:
      https://github.com/jenkinsci/jenkins/blob/a197999c6c57ad761f7242b9f6b28c0333175601/core/src/main/java/hudson/model/AbstractBuild.java#L781

      But in actuality all build steps run even if one fails (though a final result of false is reported):
      https://github.com/jenkinsci/jenkins/blob/a197999c6c57ad761f7242b9f6b28c0333175601/core/src/main/java/hudson/model/AbstractBuild.java#L724

      It looks like their is absolutely no way that git-publish could know that Crap4J failed unless Crap4J changes the build result when it has a failure.

        Attachments

          Activity

          Hide
          dlindner dlindner added a comment -

          I added the change to the build result, but left the return value as false, because it's nearer to the specification.

          Hopefully, this resolves all problems and still adheres to the intended usage.

          Show
          dlindner dlindner added a comment - I added the change to the build result, but left the return value as false, because it's nearer to the specification. Hopefully, this resolves all problems and still adheres to the intended usage.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Daniel Lindner
          Path:
          src/main/java/hudson/plugins/crap4j/Crap4JPublisher.java
          http://jenkins-ci.org/commit/crap4j-plugin/0a380cba906c0644e4bb596818aced505d9fa9f8
          Log:
          Set build result to FAILURE if no reports are found. Fixes https://issues.jenkins-ci.org/browse/JENKINS-24912

          Compare: https://github.com/jenkinsci/crap4j-plugin/compare/d6431ab28fa4...0a380cba906c

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Lindner Path: src/main/java/hudson/plugins/crap4j/Crap4JPublisher.java http://jenkins-ci.org/commit/crap4j-plugin/0a380cba906c0644e4bb596818aced505d9fa9f8 Log: Set build result to FAILURE if no reports are found. Fixes https://issues.jenkins-ci.org/browse/JENKINS-24912 Compare: https://github.com/jenkinsci/crap4j-plugin/compare/d6431ab28fa4...0a380cba906c
          Hide
          dlindner dlindner added a comment -

          Hello Loren,

          just a quick reply: I'm on a tight schedule right now, but will look into this matter in mid-October 2014. If I have any questions then, I will contact you. Expect a new version with this issue fixed probably in late October 2014.

          Show
          dlindner dlindner added a comment - Hello Loren, just a quick reply: I'm on a tight schedule right now, but will look into this matter in mid-October 2014. If I have any questions then, I will contact you. Expect a new version with this issue fixed probably in late October 2014.

            People

            • Assignee:
              dlindner dlindner
              Reporter:
              wiseloren Loren Klingman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: