How to set sonar.projectBaseDir in SonarQube Scanner for Jenkins?
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
Related videos on Youtube
dur
Updated on June 04, 2022Comments
-
dur almost 2 years
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=/copyI tried following ways to set the
sonar.projectBaseDir
property to right module (module2
instead ofmodule1
):-
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.
-