Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jacoco coverage in Jenkins Pipeline

Can anyone suggest if there is a way to execute Jacoco in a Jenkins Pipeline? I have downloaded the plugin but I do not get the option for Jacoco in the 'Pipeline Syntax', which is the Pipeline script help .

Referred this URL: https://wiki.jenkins-ci.org/display/JENKINS/JaCoCo+Plugin which has no information for a jenkins jacoco pipeline

like image 399
user5917011 Avatar asked Jan 27 '17 12:01

user5917011


People also ask

How do I use JaCoCo in Jenkins?

Run the job [JaCoCo plugin] build/*. exec;build/*-classes;src/java,src/*/java,src/*/src; locations are configured [JaCoCo plugin] Number of found exec files: 5 [JaCoCo plugin] Saving matched execfiles: .../build/jacoco-excelant. exec .../build/jacoco-main. exec .../build/jacoco-ooxml-lite.

How does Jenkins show code coverage?

If you click on the Coverage Report icon, you will see code coverage for each package in your application, and even drill down to see the code coverage (or lack thereof) for an individual class (see Figure 2.31, “Jenkins lets you display code coverage metrics for packages and classes”).


1 Answers

The jacoco pipeline step configuration uses this format:

step([$class: 'JacocoPublisher',        execPattern: 'target/*.exec',       classPattern: 'target/classes',       sourcePattern: 'src/main/java',       exclusionPattern: 'src/test*' ]) 

Or with a simpler syntax for declarative pipeline:

jacoco(        execPattern: 'target/*.exec',       classPattern: 'target/classes',       sourcePattern: 'src/main/java',       exclusionPattern: 'src/test*' ) 

You can find more options in the JaCoCo Pipeline Steps Reference

like image 64
user2688838 Avatar answered Sep 21 '22 10:09

user2688838