是否可以从命令行告诉 Sonar 项目名称? [英] Is it possible to tell Sonar the project name from the command line?

查看:14
本文介绍了是否可以从命令行告诉 Sonar 项目名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于在我公司创建的每个项目,Sonar 都会使用新的命名约定.所以有些项目的名称是缩写的,有些项目的名称是驼峰式的,有些项目的名称只是带有空格的单词.

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.

如果我们可以向 sonar-runner 传递一个 project-name 参数,那么我们就可以让集成团队(2-3 人)设置这些值,而不是每个项目的负责人(10 多个可能的人).

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.

是否可以调用 sonar-runner --rootProject='my project' 之类的东西并拥有它?我已经尝试过 sonar-runner -DprojectName=$name.

Is it possible to call something like sonar-runner --rootProject='my project' and have it? I already tried sonar-runner -DprojectName=$name.

推荐答案

你很接近,sonar.projectName 就是你要找的.看看这个记录在案的 分析参数列表.

You're close, sonar.projectName is what you're looking for. Have a look at this documented list of Analysis Parameters.

请注意,某些 SonarQube 扫描仪具有特定的行为,例如:

Note that some SonarQube Scanners have specific behaviours, for example:

  • 在任何情况下,Maven 的扫描器都会从项目定义本身获取值(例如,sonar.projectName 是项目的 属性)

Gradle 扫描仪 默认为 project.名称

但在使用标准扫描器 (sonar-runner) 时,通过显式设置 sonar.projectName 来控制事情确实是个好主意.

But when using the standard Scanner (sonar-runner) it's indeed a good idea to keep things under control by explicitly setting sonar.projectName.

这篇关于是否可以从命令行告诉 Sonar 项目名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆