如何在 SonarQube Scanner for Jenkins 中设置 sonar.projectBaseDir? [英] How to set sonar.projectBaseDir in SonarQube Scanner for Jenkins?
问题描述
我尝试使用
日志:
/Users/test/jenkinsslave/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner -X -e -Dsonar.host.url=http://sonarqube:9090-Dsonar.projectBaseDir=./../module2
I try to analyze one module of a multi module project in Jenkins with SonarQube Scanner plug-in (version 2.5). Unfortunately, Jenkins picks the wrong module as working directory.
In this particular case, I could change the order of the modules, but in general (more than one analyzed module) it is not working. So I want to fix the problem with the property sonar.projectBaseDir
, see Advanced SonarQube Scanner Usages:
Alternate Analysis Directory
If the files to be analyzed are not in the directory where the analysis starts from, use the
sonar.projectBaseDir
property to move analysis to a different directory. E.G. analysis begins fromjenkins/jobs/myjob/workspace
but the files to be analyzed are inftpdrop/cobol/project1
.sonar-project.properties
sonar.projectBaseDir=/home/ftpdrop/cobol/project1
sonar.sources=src
sonar.cobol.copy.directories=/copy
I tried following ways to set the sonar.projectBaseDir
property to right module (module2
instead of module1
):
sonar.projectBaseDir
insonar-project.properties
fileBut it doesn't work. The property in
sonar-project.properties
file is ignored. The log shows that the property is overriden with JVM option:/Users/test/jenkinsslave/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner -X -e -Dsonar.host.url=http://sonarqube:9090 -Dproject.settings=/Users/test/jenkinsslave/workspace/Test/module2/sonar-project.properties -Dsonar.projectBaseDir=/Users/test/jenkinsslave/workspace/Test/module1
I think that is a bug in SonarQube Scanner plug-in, because
project.settings
is incompatible withsonar.projectBaseDir
, see Advanced SonarQube Scanner Usages:The property
project.settings
can be used to specify the path to the project configuration file (this option is incompatible with theproject.home
andsonar.projectBaseDir
properties).sonar.projectBaseDir
as JVM OptionsBut it doesn't work. The property is ignored. The log shows that the property is overriden:
/Users/test/jenkinsslave/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner -X -e -Dsonar.host.url=http://sonarqube:9090 -Dsonar.projectBaseDir=/Users/test/jenkinsslave/workspace/Test/module1
sonar.projectBaseDir
as Additional argumentsBut it doesn't work. The log shows that the property is configured twice:
/Users/test/jenkinsslave/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner -Dsonar.projectBaseDir=/Users/test/jenkinsslave/workspace/Test/module2 -X -e -Dsonar.host.url=http://sonarqube:9090 -Dsonar.projectBaseDir=/Users/test/jenkinsslave/workspace/Test/module1
I think that is a bug in SonarQube Scanner plug-in, because it should not add
sonar.projectBaseDir
option if there is already such option.
I found a solution, I have to add the property sonar.projectBaseDir
as Analysis properties.
Configuration:
Log:
/Users/test/jenkinsslave/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner -X -e -Dsonar.host.url=http://sonarqube:9090 -Dsonar.projectBaseDir=./../module2
这篇关于如何在 SonarQube Scanner for Jenkins 中设置 sonar.projectBaseDir?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!