0

I'm trying to integrate jacoco with jenkins. For now, whenever there's a push, jenkins detects and runs the jenkins file, where I have a stage for JaCoCo, that looks as follow and working:

if(runJaCoCo){
    stage('JaCoCo'){
            jacoco(
            )
            }
}

My pom.xml looks as follow:

<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>com/Abc/Bcd/Cde/*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution> 
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>

                    </execution>
                </executions>
            </plugin>

To simplify, my problem is that whenever I open the report in Jenkins, instead of not showing the package, it shows 0% for all files under Cde, which is making the report look worst than before.

I'm expecting that the report doesn't show at all the packages, instead of showing 0% for them.

  • probably you wan't to exclude it [also in `report`](https://www.eclemma.org/jacoco/trunk/doc/report-mojo.html#excludes) execution!? :) (or generally : in plugin/-management) – xerx593 Dec 19 '22 at 13:26
  • 1
    You mean adding the exclusion to 'report' goal? If yes, I already tried that, without success :( – Ricardo Quino Dec 19 '22 at 13:27
  • problem could be in: value, try `**` (it follows ant style path matching syntax, and refers to class (files!) ... https://www.baeldung.com/jacoco-report-exclude) ..but of course also: somewhere in the "pipe"/ci... – xerx593 Dec 19 '22 at 13:32
  • "* matches zero or more characters ** matches zero or more directories ? matches a single character" – xerx593 Dec 19 '22 at 13:34
  • Tried that, but it is still showing 0% coverage for 'Cde'. It is being "ignored", but I want it to completely disappear from my report, in order to not affect it. – Ricardo Quino Dec 19 '22 at 13:42
  • sorry, cannot reproduce in "jacoco report", but "in sonar" ... – xerx593 Dec 19 '22 at 14:04
  • Is the report of jacoco generated furthermore have you configured the jacoco plugin in Jenkins? – khmarbaise Dec 19 '22 at 17:20
  • @khmarbaise I have just installed the jacoco plugin in jenkins, and then added the stage as shown above. – Ricardo Quino Dec 19 '22 at 17:25
  • have you checked the workspace if the reports is being generated and checked your configuration in your Maven project is correct? Have you checked if this works if run locally ? Do you see some reports ? – khmarbaise Dec 19 '22 at 17:26
  • @khmarbaise how do I do that? im quite new to this, but im guessing you are refering to “Run tests with coverage” option. Btw, Im using Intellij – Ricardo Quino Dec 19 '22 at 17:31
  • Run on plain command line .... is the jacoco plugin within pluginManagement tags in the pom.xml or related to a profile? – khmarbaise Dec 19 '22 at 18:17

0 Answers0