问题
With each project created at my company, a new naming convention is used in Sonar. So some projects have their name as abbreviated, and some have their names as camel case, and some projects just have their names as words with spaces.
If we could pass sonar-runner
a project-name
parameter, then that would let us have these values set by the integrations team (2-3 people), instead of the head of each project (10+ possible people).
I feel like this may force us to create a Sonar rule for sonar properties, which is entirely too meta.
Is it possible to call something like sonar-runner --rootProject='my project'
and have it? I already tried sonar-runner -DprojectName=$name
.
回答1:
You're close, sonar.projectName
is what you're looking for. Have a look at this documented list of Analysis Parameters.
Note that some SonarQube Scanners have specific behaviours, for example:
the scanner for Maven will in any case take values from the project definition itself (e.g.
sonar.projectName
is the project's<name>
attribute)the scanner for Gradle defaults to
project.name
But when using the standard Scanner (sonar-runner
) it's indeed a good idea to keep things under control by explicitly setting sonar.projectName
.
来源:https://stackoverflow.com/questions/35648627/is-it-possible-to-tell-sonar-the-project-name-from-the-command-line