I tried running a sonar analysis using a java project on Jenkins using the standard maven sonar:sonar goal and also using the post step>> Execute SonarQube scanner. The maven goal I used is.
clean org.jacoco:jacoco-maven-plugin:0.7.8:prepare-agent package org.jacoco:jacoco-maven-plugin:0.7.8:report sonar:sonar -Dmaven.test.failure.ignore=true
For SonarQube scanner I used the below maven goal
clean org.jacoco:jacoco-maven-plugin:0.7.8:prepare-agent package org.jacoco:jacoco-maven-plugin:0.7.8:report -Dmaven.test.failure.ignore=true
and in the Post step, I added Execute SonarQube scanner step.
Using maven sonar:sonar goal, I got 60% coverage and using the post step, I got only 49%. Not able to figure out the reason for the difference.
SonarQube version - 7.7 Sonar Scanner version - 3.3.0 Jenkins version - 2.164.3 Maven version - 3.6.1
I had mentioned sonar source directory different for both the runs. For maven, it was picked from pom.xml where it was src/main and for sonar scanner it was configured in the job as src. After changing it, the issue got resolved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.