sonar4stash rest api causing exception in Stash

michael_giroux January 29, 2016

We are getting the following exception in Stash when reviewing a pull request.  This exception began after upgrading SonarQube to 5.3.

 

2016-01-28 20:00:35,915 ERROR [http-nio-8080-exec-1018] michael_giroux @17KNLFXx1200x12511000x6 msajgq 172.22.8.70 "GET /rest/sonar4stash/1.0/sonarissues HTTP/1.1" c.a.p.r.c.e.j.ThrowableExceptionMapper Uncaught exception thrown by REST service: JSONObject["pages"] not found.
org.json.JSONException: JSONObject["pages"] not found.
at org.json.JSONObject.get(JSONObject.java:422) ~[json-20070829-1.jar:na]
at org.json.JSONObject.getInt(JSONObject.java:483) ~[json-20070829-1.jar:na]
at ch.mibex.stash.sonar4stash.sonar.DefaultSonarClient.ch$mibex$stash$sonar4stash$sonar$DefaultSonarClient$$toPagingInfo(DefaultSonarClient.scala:134) ~[plugin_1120250090807200834_sonar4stash-1.3.3_1454032655000.jar:n

3 answers

1 accepted

1 vote
Answer accepted
Mibex_Software
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2016

Hi,

Which version of the plug-in are you using? Please note that version 1.4.0 is not compatible with SonarQube 5.2/5.3. You have to upgrade to plug-in version 1.5.0.

Hope that helps.

Best regards,

Michael

michael_giroux January 29, 2016

Sorry for the out of order replies.  I suspect a configuration issue, but I'm not sure what to change.

we have Jenkins post build step that is generating sonar data, but the pull requests don't link to it. 

 

see the other two posts that did not link to your question.

0 votes
michael_giroux January 29, 2016

With version 1.5.0 installed, I'm seeing this:

2016-01-29 07:56:57,690 WARN [http-nio-8080-exec-1188] michael_giroux @17KNLFXx476x12533224x9 11cu9ts 172.22.8.70 "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.i.IssuesInPullRequestCollector SONAR:choicehotels.devops:test does not match the determined one from the build files choicehotels:test

and a few others like this:


2016-01-29 07:56:59,485 WARN [http-nio-8080-exec-1195] leon_mattie @17KNLFXx476x12533225x7 1jh80nz 172.22.72.131 "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.s.SonarStatisticsResource SONAR: 404 failed to retrieve statistics: Not Found
2016-01-29 07:57:01,762 WARN [http-nio-8080-exec-1188] leon_mattie @17KNLFXx477x12533244x7 1jh80nz 172.22.72.131 "GET /rest/sonar4stash/1.0/statistics HTTP/1.1" c.m.s.s.s.s.SonarStatisticsResource SONAR: 404 failed to retriev

 

Mibex_Software
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2016

Your Jenkins configuration is fine and should work with SonarQube 5.3 as well.

The error message you get means that the SonarQube project key you defined in the repository settings of the plug-in does not match the one from your build files. Has that changed lately? Could you please try to change your project key in the repository settings to "choicehotels:test"?

What kind of build system are you using to trigger SonarQube (Gradle, Maven, SonarRunner)? If changing the project key does not help, you could try to switch to the "compatibility mode" in the plug-in settings which behaves like version 1.3.3.

michael_giroux January 29, 2016

Thanks for the pointers.  I now have a pull request with stats in the overview and sonar issues flagged in the diff view.

It looks like the update to version 1.5.0 was the root cause.  Other issues came about due to a source change I made trying to dig into this.

FWIW, I did not find anything on the internet describing the error I got from the 1.3.3.version:

ThrowableExceptionMapper Uncaught exception thrown by REST service: JSONObject["pages"] not found.

 

I might have solved this myself if the plugin logged a warning that a version conflict may exist. Just thinking out loud smile

 

Again, thanks for the help.

Mibex_Software
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2016

Glad to here that it worked for you!

You're absolutely right. We will log a warning in this case for the next version of the plug-in. I have also added it to our knowledge base (see https://mibexsoftware.atlassian.net/wiki/pages/viewpage.action?pageId=29917196).

michael_giroux January 29, 2016

Thanks for updating the KB. 

0 votes
michael_giroux January 29, 2016

At the time of the stack trace, we had 1.3.3. installed.  Misread the comparability matrix.

However, we had tried 1.5.0, and that was giving us issues as well.

Background -- we are building in Jeniins and are using a post build step described in Atlassian wiki. Does this need to be refined for the current configuration (SonarQube 5.3 + sonar4stash 1.5.0)

#!/bin/bash
# --------------------------------------------------------------
# A post-build script to parse the GIT_BRANCH variable into a
# simple branch name suitable for use as a sonar project name.
# Ref: sonar3stash plugin
# https://mibexsoftware.atlassian.net/wiki/display/SONAR4STASH/Jenkins
# --------------------------------------------------------------
echo "GIT_BRANCH: ($GIT_BRANCH)"
echo SONAR_BRANCH=$(printf '%s' $GIT_BRANCH | cut -d'/' -f 2- | sed s/[^0-9a-zA-Z:_.\-]/'_'/g) | tee sonar-branch

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events