Gradle SonarScanner Pull Request Decoration Not Working W/ BitBucket Server

  • Versions:
    SonarQube 8.8, Gradle 6.8.3

  • error observed:
    None. Sonarqube says decorator was successful:
    2021.05.26 19:39:47 INFO ce[...][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request decoration | status=SUCCESS | time=188ms 2021.05.26 19:39:48 INFO ce[...][o.s.c.t.CeWorkerImpl] Executed task | project=... | type=REPORT | pullRequest=6008 | id=... | submitter=joe11150 | status=SUCCESS | time=3693ms

  • steps to reproduce
    Turn on Code Insights with com.sonarsource.sonarqube.
    Create a PR that runs gradle sonarscanner command:
    ./gradlew sonarqube -Dsonar.login=$SONAR_LOGIN -Dsonar.projectKey=... -Dsonar.host.url=https://sonarqube...

  • potential workaround
    None that I know of

Here’s 150 surrounding TRACE logs of the project=PRODENG_ghost-testfork pullRequest=2 REPORT being created:

sonarqube.log (62.5 KB)

Hi,

Welcome to the community!

Sorry you didn’t get an answer earlier.

In fact, PR decoration happens server-side, not analysis-side. The success message you’re seeing in the logs is telling you that analysis itself succeeded. For PR decoration, you’ll need to check the server-side logs, specifically the background task logs, I think.

 
Ann

Hi Ann. Thanks for the reply! Where can I get this server side log? I’m running Sonarqube in Kubernetes and this was from the pod logs. Should I exec into the pod and look for other logs?

Hi,

In the UI, go to your project → Project Settings → Background Tasks. Then look under the cog menu for the individual tasks. That’s where I believe you’ll find any pertinent logging.

 
Ann

Thanks, Ann. I see the following warnings:

SonarScanner will require Java 11 to run, starting in SonarQube 9.x. Please upgrade the version of Java that executes the scanner.

Missing blame information for 1 file. This may lead to some features not working correctly. Please check the analysis logs.

Hi,

Did you actually configure the integration?

 
Ann

I have Bitbucket configured with the ALM integration. Here is the gradle command I’m using:

./gradlew sonarqube
-Dsonar.login=$SONAR_LOGIN
-Dsonar.projectKey=GHOST_ghost
-Dsonar.host.url=https://sonarqube.gh.st

I also have the scanner context that just shows the plugins, settings, and scanner properties.

Hi,

You need to do some server-side configuration so SonarQube knows where your BB instance is & how to talk to it.

 
Ann

I’ve done this. I followed the Sonarqube “Setting your global ALM intgegration settings.” I even have another repo working with PR decorations. It’s just this one repo that doesn’t work and I don’t know why. here are the steps I followed to connect BB to Sonarqube:

Setting your global ALM Integration settings

To set your global ALM Integration settings, navigate to Administration > ALM Integrations , select the Bitbucket tab, and select Bitbucket Server as the variant you want to configure. From here, specify the following settings:

  • Configuration Name (Enterprise and Data Center Edition only) – The name used to identify your Bitbucket Server configuration at the project level. Use something succinct and easily recognizable.
  • Bitbucket Server URL – your instances URL. For example, https://bitbucket-server.your-company.com .
  • Personal Access Token – A Bitbucket Server user account is used to decorate Pull Requests. We recommend using a dedicated Bitbucket Server account with Administrator permissions. You need a Personal Access Token from this account with Read permission for the repositories that will be analyzed. This personal access token is used for pull request decoration, and you’ll be asked for another personal access token for importing projects in the following section.

This shows that configuration is good.

Hi,

Thanks for the confirmation & the screenshot. I’m officially out of my depth now & I’ve flagged this for the experts.

 
Ann

1 Like

Thanks, Ann. I look forward to the escalation of support.

Hey @joereyna ,
I can see that your global configuration is alright, how about the PR Decoration configuration?
This has to be set on a project level.
Can you check that everything is alright on this side?
(Go to your project > Project settings > ALM Integration )

BTW this has been improved on our latest 9.0 version. In case you can upgrade, the experience is better :wink:

1 Like

Here’s my “Pull Request Decoration” setting on the project in question:

I want to upgrade to Sonarqube 9, but I’m not sure our gradle project can use Java 11 yet. I’ll find out.

I’ve confirmed that our gradle project can’t use Java 11 yet. I’d love it if we could get this working.

@joereyna Could your issue be related to this ticket (case sensitivity for the slug field)? https://jira.sonarsource.com/browse/SONAR-14629

@Christophe_Havard I don’t think so. My bitbucket server project and repo names have matching cases with what’s configured on Sonarqube:

For now I have no idea why PR deco would not happen with your config. I’ll pass on to the next expert :sweat_smile:
Btw, what is your SQ edition?

  • Version 8.8 (build 42792)