Issue with sonar.organization with self-hosted Sonar instance

Hi,

My goal is to add xwiki-platform analysis to our own sonarqube instance (along with code coverage).

I’m able to build the project by following build instruction but still, I’m facing the following issue when invoking the sonar:sonar goal

Caused by: org.sonarqube.ws.client.HttpException: Error 404 on
https://sonarqube.ow2.org/api/qualityprofiles/search.protobuf?defaults=true&organization=xwiki :
{"errors":[{"msg":"No organization with key 'xwiki'"}]}

(Notice that I’m using the settings.xml provided in the build guide)

As far as I understand, in the parent POM at https://github.com/xwiki/xwiki-commons/blob/8e91e4db2a19e7ef5dd623cca76c290a2bf6da0b/pom.xml#L177 a sonar.organization property is defined that a self-hosted instance of SonarQube cannot take into account as it is intended for SonarCloud usage only.

So I’m looking for tips in order not to have the property defined when invoking sonar:sonar goal. Any idea ?

Thanks

If all you need is to have this property not set then it’s possible adding -Dsonar.organization= to the build command line helps.

In which case I get:

Caused by: org.sonarqube.ws.client.HttpException: Error 404 on https://sonarqube.ow2.org/api/qualityprofiles/search.protobuf?defaults=true&organization= : {"errors":[{"msg":"No organization with key ''"}]}

I wonder how the parameters string is generated…

OK. Not sure if there is a way in the commend like to unset a property but seems that’s what you need. Or maybe this sonar plugin only works with sonar cloud ? I find very weird that the server take into account the sent organization if it does not know the concept of organization. Maybe you can put XWiki in the “xwiki” organization in your sonar instance.

I would be glad to but organization concept is not part of the self-hosted distribution of SonarQube

So I made a step forward thank to the help of the Sonar Community :

Now, I’m facing this issue… (that’s too bad isn’t ?):

And got no answer, yet.

It wasn’t easy at all but I finally made it !! https://sonarqube.ow2.org/dashboard?id=org.xwiki.platform%3Axwiki-platform
The second issue with postgres solved by itself by updating sonarqube to the latest LTS version.

Cool :slight_smile: What was the key element to make it work in the end?

Note that your coverage doesn’t seem to include integration/functional tests since it should be around 70% normally.

Also I couldn’t find xwiki commons nor xwiki rendering in your sonarqube instance. Are you going to add them?

Thanks!

two key elements:

  1. sonar.organization should be set to default-organization for self-hosted instance
  2. to solve the server-side postgres issue, upgrade sonarqube from 6.7.6 to 7.9.1

Note: the job definition I’m using is https://gitlab.ow2.org/ow2/oscar/xwiki/blob/master/.gitlab-ci.yml . This is done in two steps 1) run tests, 2) run sonar. (maybe two steps can be merge in one).

I’m using clean install -Pcoverage to run some tests. You advised -Plegacy,quality,integration-tests in https://gist.github.com/vmassol/046666e7314fbb6d7d4f07740e076cf2

I wonder why coverage isn’t need in yours. Maybe it’s inherited so I might give it a try anyway unless you have a better suggestion.

I would need to read the pom to understand what is this coverage profile :wink: I don’t see it documented on https://dev.xwiki.org/xwiki/bin/view/Community/Building/#HUsingProfiles. What’s sure is that functional tests are only executed if you have both integration-tests and docker profiles. The quality profile is also not needed for your use case.

what about this point? :slight_smile: Thx!

I’ve been focusing on xwiki-platform because unless I’m wrong, no one have recent source-code metric to offer on this component. I can retrieve commons and rendering from you sonarcloud instance I guess.

Also , as XWiki has several components the next step is to find a way to merge all those individual component metrics to a unique place, and proceed with MRL computation with the help of CROSSMINER (EU project), and display it on the OW2 xwiki dashboard. We haven’t studied how to merge them yet. Until we achieve that and in a first step, the MRL metrics about source code will be taken from xwiki-platform only. So it won’t be 100% representative of the whole XWiki project source-code wise for a start, but that’s the goal.