简体   繁体   中英

SonarQube build breaker and Jenkins quality gates not same

I have SonarQube (v6.7) installed using sonar-build-breaker-plugin-2.2 for quality gates. I have Jenkins (v2.161) installed with Sonar Quality Gates Plugin (v1.3.1) installed in different Servers. Below is the configuration of the Quality gates in Jenkins

在此处输入图片说明

I have configured the Project key and Job status as FAILED in the job configuration. The problem is, when the SonarQube analysis for a project is triggered from maven using cmd prompt, it is passed successfully. When the same job is triggered from Jenkins I am getting below error.

07:03:50 [INFO] Quality gate status: ERROR
07:03:50 [ERROR] Security Rating on New Code: 4 > 1
07:03:50 [ERROR] Reliability Rating on New Code: 4 > 1
07:03:50 [ERROR] [BUILD BREAKER] Project did not meet 2 conditions
07:03:51 [INFO] ------------------------------------------------------------------------
07:03:51 [INFO] BUILD FAILURE
07:03:51 [INFO] ------------------------------------------------------------------------
07:03:51 [INFO] Total time: 02:17 min
07:03:51 [INFO] Finished at: 2019-02-06T07:03:51+01:00
07:03:51 [INFO] ------------------------------------------------------------------------
07:03:51 Waiting for Jenkins to finish collecting data
07:03:52 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project Project-company-lib: Project does not pass the quality gate. -> [Help 1]
07:03:52 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project Project-company-lib: Project does not pass the quality gate.

What am I missing here?

Thanks in advance.

The reason for the difference in report for SonarQube trigger and Jenkins Job is that, I have a configuration in SonarQube to analyse only .java,.jav files .In the SonarQube UI, Configurations --> General Settings --> Java, this configuration is available.

The project consists of .java,.xml,.xhtml files, so in order to skip the files other than java, I have included a configuration -Dsonar.language=java in the Jenkins goal and now the report is same. Though this configuration is said to be deprecated, it works fine for now.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM