Failed to create Bitbucket Server Quality Report

sonarqube
bitbucket
pull-request

(Alban Fonrouge) #1

Hi,

I am using SonarQube 7.7 Developer Edition together with Bitbucket Server 5.9.0.
The PR analysis is working, but I tried to setup the PR decoration and I get this warning:
“Failed to create Bitbucket Server Quality Report for commit SHA ‘xxxxxxxxxxxxxxxxxxxxx’”.
And I can’t find anything else in the logs.

Here are the parts of the Scanner Context which I think are relevant:

Global server settings:

  • sonar.pullrequest.bitbucketserver.serverUrl=https://stash.company.com/
  • sonar.pullrequest.bitbucketserver.token.secured=******
  • sonar.pullrequest.provider=Bitbucket Server
    Project server settings:
  • sonar.pullrequest.bitbucketserver.project=AC
  • sonar.pullrequest.bitbucketserver.repository=lib-document-messages

Project scanner properties:

  • sonar.pullrequest.base=master
  • sonar.pullrequest.branch=PR-2
  • sonar.pullrequest.key=2

What am I missing?

Thanks,

Alban


(Alban Fonrouge) #2

I raised the log level to TRACE and I got this error:

2019.03.25 13:33:26 DEBUG ce[AWm0oFudNKbscBpl5JWA][c.s.C.C.A.A.C] Unable to contact Bitbucket server: 403 <!doctype html><html lang="en"><head><title>HTTP Status 403 – Forbidden</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 403 – Forbidden</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The server understood the request but refuses to authorize it.</p><hr class="line" /></body></html>

It’s not the same error I get when I call the API with an incorrect token:

{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}

So I guess the URL is wrong in some way.

I tried that with a real token and it worked:

curl -H "Authorization: Bearer Mzxxxxxxxxxxxxxxxxxx" https://stash.company.com/rest/api/1.0/projects/AC/repos/lib-document-messages/commits/?until=master

Could you confirm how the url is constructed from the configuration parameters?


(Michal Duda) #3

Hello Alban,

Can you please recheck without the trailing slash (sonar.pullrequest.bitbucketserver.serverUrl=https://stash.company.com)?


(Josiah Eubank) #4

I have a similar, but different (due to not being an authentication problem) issue and have opened a new thread here: Failed to create Bitbucket Server Quality Report - HTTP 400 - annotations required


(Mark Bretl) #5

Hello,

I have the same issue when trying to decorate my PR in Bitbucket Server. My Bitbucket Server version is 5.9.1 and SonarQube is 7.7.0.

Here is my configuration:
Global server settings:

  • sonar.pullrequest.bitbucketserver.serverUrl=https://bitbucket.company.com
  • sonar.pullrequest.bitbucketserver.token.secured=******
  • sonar.pullrequest.provider=Bitbucket Server
    Project server settings:
    Project scanner properties:
  • sonar.host.url=https://sonarqube.company.com
  • sonar.pullrequest.base=master
  • sonar.pullrequest.bitbucketserver.project=MyProject
  • sonar.pullrequest.bitbucketserver.repository=MyRepo
  • sonar.pullrequest.branch=PR-99
  • sonar.pullrequest.key=99
  • sonar.scanner.app=ScannerCli
  • sonar.scanner.appVersion=3.0.3.778

I tried with and without the ‘/’ on the Bitbucket server URL, both gave the same 403 error. The pull request link on the SonarQube pull request page does have the correct link, so it seems like SonarQube has the correct information.

So close to get this working…

Let me know if there is anything else I can supply or help with.

–Mark


(Mark Bretl) #6

I think I have found it…

In my Bitbucket server access log I see the following…
/rest/insights/1.0/projects/myProject/repos/My Repo/commits/70b82ba14a874d9c6d3a54fcac320307a4ed558a/ | … | 403

This looks like it is using the INSIGHTS API, which was not released in Bitbucket Server until 5.15. Since I am only using 5.9.1, the ‘feature’ of PR decoration will not work.

If this is the case, please add a note on the 7.7 documentation page, https://docs.sonarqube.org/7.7/analysis/pull-request/, stating must have minimum BitBucket Server 5.15.

–Mark


(Alban Fonrouge) #7

Great find, I didn’t have access to the bitbucket logs.
I’ve requested an upgrade :slight_smile: