简体   繁体   English

SonarQube 中同一项目的多个视图

[英]Multiple views of same project in SonarQube

Is there a way to have multiple views of the same java project which is being built by go-server in seperate pipelines with each pipeline building different git branch.有没有办法让 go-server 在单独的管道中构建同一个 java 项目的多个视图,每个管道构建不同的 git 分支。

go-job : mvn sonar:sonar -Dsonar.host.url=http://localhost:9000去工作: mvn sonar:sonar -Dsonar.host.url=http://localhost:9000

Each pipeline once successfully built overwrites previous view since the maven project is same.由于 Maven 项目相同,因此成功构建的每个管道都会覆盖以前的视图。 Wondering if I can differentiate sonar project using branch identifier or via other command parameter so that overwrite doesnt happen.想知道我是否可以使用分支标识符或通过其他命令参数来区分声纳项目,以便不会发生覆盖。

To analyze multiple instances of the same project, you can use the sonar.projectKey property to differentiate the project.要分析同一项目的多个实例,您可以使用sonar.projectKey属性来区分项目。

Example: mvn sonar:sonar -Dsonar.projectKey=my-first-project-key示例: mvn sonar:sonar -Dsonar.projectKey=my-first-project-key

I have encountered same issue and found solution, hope this will help someone.我遇到了同样的问题并找到了解决方案,希望这会对某人有所帮助。 Whatever project key is generated while login (token generated), you can get the same token and build your project like below.无论登录时生成什么项目密钥(生成令牌),您都可以获得相同的令牌并构建您的项目,如下所示。 I assume that you are able to view sonar dashboard.我假设您能够查看声纳仪表板。 Assume you have 3 projects假设你有 3 个项目

  1. A project一个项目
  2. B project B项目
  3. C project C项目

Build your A project as将您的 A 项目构建为

  • mvn sonar:sonar -Dsonar.projectKey=A -Dsonar.host.url= http://localhost:9000 -Dsonar.login=your token goes here mvn sonar:sonar -Dsonar.projectKey=A -Dsonar.host.url= http://localhost:9000 -Dsonar.login=你的令牌在这里

Build your B project as将您的 B 项目构建为

  • mvn sonar:sonar -Dsonar.projectKey=B -Dsonar.host.url= http://localhost:9000 -Dsonar.login=your token goes here mvn sonar:sonar -Dsonar.projectKey=B -Dsonar.host.url= http://localhost:9000 -Dsonar.login=你的令牌在这里

and similarly build third one as well.并同样构建第三个。 Here what exactly is happening, -Dsonar.projectKey will take the project and it will post the generated report for given project to the token provided for localhost:9000 url.这里到底发生了什么,-Dsonar.projectKey 将接受该项目,并将为给定项目生成的报告发布到为 localhost:9000 url 提供的令牌。 So how many projects you have it will show the reports for all in the sonar dashboard.因此,您拥有多少个项目将在声纳仪表板中显示所有报告。

please try this and if this works then hit the like button :)请尝试此操作,如果有效,请点击“赞”按钮 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM