Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an "Error while reading the sourcefile!" error from Jenkins jacoco plugin

My source code is written in scala. I have used sbt-jacoco sbt plugin of version 3.0.3 for code coverage. Jenkins plugin used is JaCoCo Plugin of version 3.0.1

I have implemented jacoco within my Jenkinsfile as :

step([$class: 'JacocoPublisher', sourcePattern: '**/src'])

The plugin works perfectly fine , shows the code percentages covered and missed. But when I go to check the actual lines of code covered through the Jenkins UI, I get the above error "Error while reading the sourcefile!"
Would you help me figure out what I am doing wrong?

Attached screenshots

error page

like image 400
Sagnik Kundu Avatar asked Jan 28 '23 13:01

Sagnik Kundu


1 Answers

look at jenkins log (usually at /var/log/jenkins/jenkins.log) for exceptions like java.io.FileNotFoundException to figure out where the plugin think the file located at, or any other errors while trying to read the file.

what solve it for me was setting the sourcePattern to '**/src/*/java' which by default it is set to '**/src/main/java' based on git

like image 91
Roi Addi Avatar answered Mar 20 '23 02:03

Roi Addi