'Exclude packages from Jacoco report using gitlab-ci.yml

I want to exclude some packages from my jacoco coverage report. I have excluded the packages in the pom.xml where I have added the jacoco plugin and it's working fine, I cannot see the excluded package in the report as expected.

      <configuration>
            <excludes>
                <exclude>**/utilities/**/*</exclude>
            </excludes>
      </configuration>

The same thing I wanted to do in the below git-ci.yml file for coverage stage.

 coverage:
  stage: coverage
  script:
    - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report
    - cat target/site/jacoco/index.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/Jacoco Coverage Total:/'
  artifacts:
    paths:
      - target/site/jacoco/jacoco.xml


cat target/site/jacoco/index.html | grep -o 'Total[^%]*%' | sed 's/<.*>/ /; s/Total/Jacoco Coverage Total:/' -- output of this is percentage coverage of entire classes in my project.

I am not sure how to achieve this using gitlab-ci?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source