how to use api/sources/scm in sonarqube-5.2?

147 views
Skip to first unread message

Victor Breygin

unread,
Dec 11, 2015, 4:31:42 PM12/11/15
to SonarQube
Hello SonarQube Team,

can somebody provide a guidance on how I can use Web services API to retrieve SCM information?
I tried the following URL on my local server:


I was expecting an information similar to what is described in http://nemo.sonarqube.org/api_documentation/api/sources

some api's seem to work fine, for example, api/projects, api/system but api/source/scm always returns HTTP 404.

is there anything I am doing wrong?

thanks in advance for your help!
victor

Julien Lancelot

unread,
Dec 14, 2015, 3:40:54 AM12/14/15
to Victor Breygin, SonarQube
Hi Victor,

What SonarQube version are you using ?
As you can see in the documentation, api/sources/scm is available since 4.4.

To see all available WS of your SonarQube instance, you can go http://localhost:9000/api_documentation/api/sources.

Regards,

Julien LANCELOT | SonarSource

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/56d80412-2b89-45cb-a616-916478a0c644%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Victor Breygin

unread,
Dec 14, 2015, 10:32:10 AM12/14/15
to SonarQube, vic...@magma.ca
Hi Julien

Thank you for writing back.
we are using sonarqube-5.2.
as I mentioned in my original post, I can't get this to work:


am I doing something wrong? Once this is resolved, I would like to use WS from ruby on rails template?

regards,
victor

Julien Lancelot

unread,
Dec 14, 2015, 10:44:53 AM12/14/15
to Victor Breygin, SonarQube
Could you send us the result of http://localhost:9000/api/sources/scm?key=MySonarProject:moduleName/classpath/className.java ?
Are you sure that your project have some SCM data ?

Julien LANCELOT | SonarSource

Victor Breygin

unread,
Dec 14, 2015, 1:45:43 PM12/14/15
to SonarQube, vic...@magma.ca
Hello Julien

thank you for your continuous support, it is really appreciated.
yes, SCM data should be there, when I ran analysis I see SCM sensor is spending some time (a few seconds) on each module of the project.

{"errors":[{"msg":"Component key 'myProject:moduleName/classpath/className.java' not found"}]}

I checked if this key exists in Projects table of H2 database and apparently there is a tiny little 
difference between what I tried and what it is expected as a key. The correct key is of the following format:

myProject:moduleName:classpath/className.java  

Note little semicolon after moduleName!!! 
it seems to work now, I just need to figure out how to compose that URL in ruby on rails template, i.e. how to get serverName, myProject, moduleName etc.

thanks a lot!

Julien Lancelot

unread,
Dec 15, 2015, 3:44:00 AM12/15/15
to Victor Breygin, SonarQube
Ok, good news, thanks for the feedback.

Julien LANCELOT | SonarSource

Reply all
Reply to author
Forward
0 new messages