Closed steelorbis closed 8 years ago
Let me dig into this a little bit, but I think it should be possible.
In order to do this I need to understand your setup so I can write a test case for this. In my setup with Sonar it always uses the groupid and artifactid as the projectkey. Do you not have those in your pom file? If not, how does Sonar pick a projectkey?
Also can you let me know what version of Sonar you are running?
Hi Shawn,
If there is no customization, sonar client submits the results to the sonar server with the default naming scheme which is
<properties>
<sonar.projectKey>${branch}:${env}:${project.artifactId}</sonar.projectKey>
</properties>
For my setup, an example project key in sonar server is SP-4212:test:parent where SP-4212 is branch name, test is the environment and parent is the artifact id of maven module.
"sonar-break-maven-plugin" is using the below url to fetch results: http://${sonarServerUrl}/api/resources/index?resource=_${groupId}:${artifactId}_&metrics=quality_gate_details
While in my case, it should be using: http://${sonarServerUrl}/api/resources/index?resource=_${sonarProjectKey}_&metrics=quality_gate_details
Here is the url to the sonar parameters page: Analysis Parameters
I have a sonarqube server 5.4, sonar-maven-plugin 3.0.1 and sonar-break-maven-plugin 1.1.2 setup.
Let me know if I can be any help to you.
This is now working with the latest source. You can view an example of this here: https://github.com/sgoertzen/sonar-break-maven-plugin/blob/master/integration-tests/custom-key/pom.xml
Note: I haven't pushed this updated version into maven-central yet. Are you able to build the source to test this in your environment and let me know if there are any issues?
Hi,
Plugin first checks to see if the project url is available and then it starts waiting for the set "waitForProcessingSeconds" value.
However if it is the first time that a project is being analysed and no previous run has been recorded on the sonar server, project url will not be available until it has been processed. So plugin should still wait for the "waitForProcessingSeconds" value regardless of the project url being available.
Currently if it is the first run for a project, plugin always fails with "Unable to get a valid response after 10 tries" error message. You could consider removing the url check.
Other than that, plugin now uses custom project keys. So it is working as expected.
Adjusted the check so it just verifies against the base sonar URL instead of the project URL.
Pushed the latest up to maven central as version 1.1.3. Might take a day for it to become available.
Thank you for the plugin. Have a nice day.
Hi,
Currently it is not available to use a custom "sonar.projectKey" property. Plugin defaults to: for resource naming. Could you enable the plugin to pick up a custom "sonar.projectKey" ?
Thanks.