How to fail build when haltOnFailure=false

96 views
Skip to first unread message

Joyce Hon

unread,
Jun 12, 2023, 1:33:27 PM6/12/23
to JaCoCo and EclEmma Users
We are using jacoco on a java library with several modules and using the check goal to check for a certain level of coverage. We use report-aggregate to get a final report. We notice that when we don't use haltOnFailure=false, then if the first module fails, no coverage report is created and subsequent modules aren't tested. This isn't ideal for us, so we used haltOnFailure=false, so now coverage reports are always generated, BUT if a check fails, the mvn command exits with code 0, which makes it look like a successful build.

Is there a way to generate all coverage reports for all modules AND fail the build if a check fails? 

Screenshot 2023-06-12 at 10.29.08 AM.png

Screenshot 2023-06-12 at 10.30.37 AM.png

We were thinking of writing some code to process the jacoco.xml and compare the report's values to the jacoco check values in the pom.xml, but this seems strange to have to do. Any help would be appreciated! Thanks!




Marc Hoffmann

unread,
Jun 12, 2023, 3:55:26 PM6/12/23
to JaCoCo and EclEmma Users
Hi,

this is simply how Maven works: One module is built after another.

You may consider using another tool like SonarQube to get the overall picture.

Cheers,
-marc



On 12. Jun 2023, at 19:33, Joyce Hon <jmh...@gmail.com> wrote:

We are using jacoco on a java library with several modules and using the check goal to check for a certain level of coverage. We use report-aggregate to get a final report. We notice that when we don't use haltOnFailure=false, then if the first module fails, no coverage report is created and subsequent modules aren't tested. This isn't ideal for us, so we used haltOnFailure=false, so now coverage reports are always generated, BUT if a check fails, the mvn command exits with code 0, which makes it look like a successful build.

Is there a way to generate all coverage reports for all modules AND fail the build if a check fails? 

<Screenshot 2023-06-12 at 10.29.08 AM.png>

<Screenshot 2023-06-12 at 10.30.37 AM.png>

We were thinking of writing some code to process the jacoco.xml and compare the report's values to the jacoco check values in the pom.xml, but this seems strange to have to do. Any help would be appreciated! Thanks!





--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/53776664-6ea9-481d-a893-d220f8baf913n%40googlegroups.com.
<Screenshot 2023-06-12 at 10.29.08 AM.png><Screenshot 2023-06-12 at 10.30.37 AM.png>

Reply all
Reply to author
Forward
0 new messages