idea maven集成sonarqube组件
场景在持续集成过程中,需要用sonarqube进行代码质量检查,为了在开发过程中进快速检查,官方提供了一种集成开发的方式。这里主要使用maven集成方式。环境配置步骤1:maven环境配置,在maven的setting.xml的pluginGroups和profiles标签中增加如下内容。<pluginGroups><!-- pluginGroup| Specifies a fu
·
场景
在持续集成过程中,需要用sonarqube进行代码质量检查,为了在开发过程中进快速检查,官方提供了一种集成开发的方式。
这里主要使用maven集成方式。
环境配置
步骤1:maven环境配置,在maven的setting.xml的pluginGroups和profiles标签中增加如下内容。
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
步骤2:idea中新增sonar检查指令

方式1:用户密码登录
sonar:sonar -Dsonar.login={userId} -Dsonar.password={password}
方式2:token令牌登录
sonar:sonar -Dsonar.login={sonarqube token}
- 生成登录令牌

第三步:执行maven命令

- 登录信息错误会显示
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:
sonar (default-cli) on project framework-export-plus:
Not authorized. Please check the properties sonar.login and sonar.password.
第四步:执行成功后在sonarqube平台上就能看到我们的信息了
扩展配置
还可以通过命令调整项目在sonarqube中的项目信息
- -Dsonar.projectName:项目名称
- -Dsonar.projectKey:项目主键
sonar:sonar -Dsonar.login=xxxx
-Dsonar.projectName=lizz-test
-Dsonar.projectKey-lizz-test-123
更多推荐


所有评论(0)