简体   繁体   中英

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-job : mvn sonar:sonar -Dsonar.host.url=http://localhost:9000

Each pipeline once successfully built overwrites previous view since the maven project is same. 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.

Example: 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

  1. A project
  2. B project
  3. C project

Build your A project as

  • mvn sonar:sonar -Dsonar.projectKey=A -Dsonar.host.url= http://localhost:9000 -Dsonar.login=your token goes here

Build your B project as

  • mvn sonar:sonar -Dsonar.projectKey=B -Dsonar.host.url= http://localhost:9000 -Dsonar.login=your token goes here

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. 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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