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

Crap4J does not correctly fail the build when reporting fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • crap4j-plugin

      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.

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

              Created:
              Updated:
              Resolved: