SonarQube Pull Request Decoration with BitBucket

Let’s discuss what you have in mind!

Try to describe the problem or opportunity you are seeing and why it matters. The closer you stick to this topic template, and the more information you provide, the better chance you have to generate a real discussion.

A few questions to help you:

  • What are you trying to accomplish? > SonarQube Pull Request Decoration with BitBucket
  • Why does this matter to you? Our Deverloper not able to see Code Analysis in Bitbucket itself even Decoration configured.
  • How would that look in SonarQube? Alternatives? not sure
  • How would we know it works well? i can provide logs
  • Why should it be a priority now? we have deadline to meet project work

Make sure to check out our product roadmap as well, to see if your need is already being considered.

Hi,

The feature is already available in SonarQube (starting with the Devloper Edition).
See Bitbucket Server integration and Bitbucket Cloud integration.

I’ll move your post out of the “Product Manager of the Day” category so that you can get help from the community to make it work.

Chris

1 Like

Hi team
Can you please let me know any action do i need to take from my end.

Hello @ashishb ,

Have you followed the documentation for pull request decoration as described in Bitbucket Server integration and Bitbucket Cloud integration?

Are you having trouble setting it up? Can you tell me what you have done so far?

Yes, i have followed up for [Bitbucket Cloud integration] document, but still facing problem to see decoration in bitbucket

We have SonarQube Publicly accessible and all pre-requisite in place. Still Bitbucket PR decoration not visible at Bitbucket end.

Kindly suggest if it is known issue and its workaround exist, kindly share with us

Can you please attach logs of your issue? Please follow the steps below and attach the following:

  1. Go to Administration > DevOps Platform Integrations > Bitbucket and take a screenshot
  2. Go to Administration > System > Logs Level > set to “DEBUG”
  3. Attempt a PR request and build/analyze it so that you can reproduce your issue
  4. Go to Administration > System > Logs Level > set to “Info”
  5. On this same screen, click on “Download logs” and select “Compute Engine” and “Web Server” logs to download them
  6. Upload/attach them here
  7. If you prefer to do this privately, just message me here and we can take this private

sonarqube_web 1.log

Hi Joe

Please review logs and let me know if you need any other information.

Regards,
AshishB

sonarqube_ce.log (4.04 MB)

sonarqube_web.zip (1.6 MB)

Hi Joe

Any clue, from logs. please let me know

Hello @ashishb ,

I sent you a private message, please check it next time so we can keep things private in case you have sensitive information. Can you follow-up with the below requests?

Project key: alconpc_ace-sx-b2b_AYfj_xl-fljaPvznLEc0

I have multiple PR 1601 1630 1288
above are some of PR

i m not sure about code in pull request, what does it mean

Please give me some clarity

please let me know if you need more details

Hi Joe

I have provided required detail.

Please let me know if you need any further information.

Regards,
AshishB

hi Joe
still looking for reply

Hello @ashishb ,

Please note that this is not commercial support and there is no expected SLA here. Commercial support will have 24hr SLA commitment.

I reviewed your logs and they do not show any obvious issue. I did not see of those pull request numbers you mentioned in the logs you attached.

Here’s what I suggest next:
2. Set DEBUG level in your Bitbucket project build (add sonar.verbose=true) to your Sonar scan analysis parameters

  1. Go to Administration > System > Logs Level > set to “DEBUG”
  2. Reproduce your issue
  3. Go to Administration > System > Logs Level > set to “Info”
  4. On this same screen, click on “Download logs” and select “Compute Engine” and “Web Server” logs to download them
  5. Take a screenshot of your Bitbucket pull request that shows the problem
  6. Attach five things here:
    1. Web Server logs
    2. Compute Engine logs
    3. Screenshot of Bitbucket pull request showing the problem
    4. Bitbucket pipeline logs
    5. Bitbucket pipline yaml

It is not Bitbucket pipeline, it is Jenkins Pipeline and I will provide you logs which you have mentioned by re-producing issue.
Even I wont be able to provide you PR decoration screenshot, since it is not getting displayed in Bitbucket portal.

Ok understood, please provide the Jenkinsfile pipeline definition and the DEBUG console logs with DEBUG SonarQube logs. I’ll stand by.

Jenkinsfile.txt (1.6 KB)
will provide required logs once PR raised by Developer

Hi @ashishb ,

The Jenkinsfile you show is unlike the typical recommendation we suggest:

stage('SonarQube Analysis') {
	steps {
		sh "cp -R /var/jenkins/hybris ."
		sh "cp core-customize/config/local.properties hybris/config/local.properties"
		sh "cp core-customize/config/localextensions.xml hybris/config/localextensions.xml"
		sh "cp -R core-customize/custom hybris/bin/custom"
		sh 'echo "jacoco.base.dir=/var/jenkins/workspace/ace-sx-b2b_${modifiedBranchName}/hybris/data/jacoco" >>  hybris/config/local.properties'
		sh 'echo "jacoco.lib.loc=/var/jenkins/workspace/ace-sx-b2b_${modifiedBranchName}/hybris/data/jacoco/agent" >>  hybris/config/local.properties'
		sh 'echo "sonar.coverage.jacoco.xmlReportPaths=/var/jenkins/workspace/ace-sx-b2b_${modifiedBranchName}/reports.xml" >>  hybris/config/local.properties'
		sh 'echo "sonar.jacoco.reportPaths=/var/jenkins/workspace/ace-sx-b2b_${modifiedBranchName}/hybris/data/jacoco/reports/jacoco2.exec" >>  hybris/config/local.properties'
		sh 'echo "sonar.branch.name=${BRANCH_NAME}" >>  hybris/config/local.properties'
		sh 'cat core-customize/config/sonar_local.properties >>  hybris/config/local.properties'
		sh "chmod -R 777 *"
		
		dir('hybris/bin/platform'){
			sh ". ./setantenv.sh && ant clean all && ant sonarcheck"
		}

		sh "rm -rf hybris"
	}
}

I recommend you reformulate your Jenkinsfile by following the project onboarding method by creating a new project and following these steps:

In this manner, you’ll create a multibranch pipeline with a step-by-step tutorial like this:

So the essential parts of your Jenkinsfile look like this (for Maven project, for example):

node {
  stage('SCM') {
    checkout scm
  }
  stage('SonarQube Analysis') {
    def mvn = tool 'Default Maven';
    withSonarQubeEnv() {
      sh "${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=sonarjoe_jojo-js_AYm0b0YHHvnwdeIpkdWD"
    }
  }
}

Hi Joe
Thanks for your response. I have already configured Jenkins multibranch pipeline but for “SonarQube Analysis” stage with withSonarQubeEnv we had Java memory error and Ant build tool and configured in Jenkins Declarative Pipeline so did not configure withSonarQubeEnv()

Exception in thread “jenkins.util.Timer [#4]” java.lang.OutOfMemoryError: Java heap space
jenkins.util.ErrorLoggingScheduledThreadPoolExecutor afterExecute
WARNING: failure in task not wrapped in SafeTimerTask
java.lang.OutOfMemoryError: Java heap space