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

Cobertura should fail the build if empty xml is generated

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • cobertura-plugin
    • None
    • cobertura-plugin 1.16

      There is no way to configure the plugin to fail the build, when given xml is in valid format but "empty" i.e. contains no information because previous generation from gcovr produced zero information because it was misconfigured. Example of the valid xml from gcovr:

      <?xml version='1.0' encoding='UTF-8'?>
      <!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
      <coverage line-rate="0.0" branch-rate="0.0" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0" complexity="0.0" timestamp="1589944199" version="gcovr 4.2"><sources><source>/var/lib/jenkins/workspace/NightlyLinux</source></sources><packages/></coverage>
      

      I would expect that if I've set the thresholds for the plugin to 50%, then values for branch-rate or line-rate 0 would fail the build – that's not the case. Build is still marked with SUCCESS.

      Example of settings:

      You can quickly check it in the freestyle job with the configuration as in the screenshot with installed

      {cobertura-1.16}

      and following shell script

      #!/bin/bash
      
      cat <<EOF > unittest_coverage.xml
      <?xml version='1.0' encoding='UTF-8'?>
      <!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>
      <coverage line-rate="0.0" branch-rate="0.0" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0" complexity="0.0" timestamp="1589944199" version="gcovr 4.2"><sources><source>/var/lib/jenkins/workspace/Check Cobertura</source></sources><packages/></coverage>
      EOF
      

      The builds are still marked as SUCCESS:

            Unassigned Unassigned
            astaruch Andrej Staruch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: