Anil Kumar
Anil Kumar

Reputation: 389

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.

Upvotes: 1

Views: 2020

Answers (2)

Kushwaha
Kushwaha

Reputation: 918

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

Upvotes: 0

Teryk - SonarSource
Teryk - SonarSource

Reputation: 994

To analyze multiple instances of the same project, you can use the sonar.projectKeyproperty to differentiate the project.

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

Upvotes: 1

Related Questions