scoverage and Parallel Stages in a Jenkins Declarative Pipeline

I have a multi-module Maven project written in Scala with over 3000 unit tests. To keep build times almost reasonable, those unit tests are run in 6 parallel stages. Complicating matters, I also need scoverage to tell us why we need 4000 unit tests 😉

The build runs first and the 6 parallel test stages after. Problem is I’m only seeing the coverage in SonarQube from the last test stage to complete. The working theory being the last stage wins the race overwriting the scoverage.xml file. I believe my problem is this line in the scoverage.maven.plugin where the file name is hard coded. [EDIT: This line is not the problem! It is simply reporting the location of the scoverage.xml file written by the ScoverageXmlWriter in the line above.]

I tried using the scoverage.xmlOutputDirectory and scoverage.dataDirectory to include the stage name in the value to isolate the scoverage.xml file for each stage in its own directory, but that appears to blow up Maven. Maybe not surprising to others since both parameters are annotated as read-only.

Am I missing the obvious and if so, what?

Leave a Comment