SonarQube Pull Request Decoration with BitBucket

If this is a different error from your Bitbucket PR issue, please start a new thread so we can try to assist you there.

Did you get the logs I requested below?

Right now, nothing you’ve shown so far shows the issue you believe you are having. Please provide the above information to allow us to help you.

Java error is not related here, since you had asked for SonarQube Analysis stage with withSonarQubeEnv() for that we were receiving that Java Error before, because of that we have configured Jenkins Pipeline as Declarative pipeline instead of Scripted one

This is Jenkins Pipeline and not Bitbucket Pipeline so I could not provide PR Decoration error since it is not visible in Bitbucket PR window.

I will share today required logs

sonarqube_web (1).log (8.6 MB)
sonarqube_ce (1).log (980.5 KB)
Find WebServer and compute logs.

Thanks, can you provide your analysis/build DEBUG logs?

find debug logs
PR-1773.txt (1.6 MB)

Hi Joe
Any luck to debug issue.

Hi Joe

Please let me know if you need any more detail or any other logs

Hello, I’m on vacation since last week. Apologies for the delay. I will assist you next week.

Ok, I am back now.

Thank you for the Jenkins log of your Ant project. Here are the issues I see with it:

  • Earlier you mentioned that you already configured a Jenkins multibranch pipeline. Can you take a screenshot of your Jenkins configuration for Branch Sources? It should look something like this if you followed the onboarding tutorial in SonarQube:
  • Your logs show that you are manually setting the sonar.branch.name manually when you should let the Jenkins SonarQube extension handle it automatically:
    sonarcheck:
         [echo]  
         [echo] ******************************************************************
         [echo] - Executing sonarcheck
         [echo] -------------------------------------------------
         [echo] - sonar.branch.name        : PR-1773
         [echo] - sonar.extensions         : alconbackoffice,alconfacades,alconcore,alconocc,alconfulfilmentprocess,alconinitialdata,alconintegration
         [echo] - sonar.projectName        : ACE-SX-B2B
         [echo] - sonar.projectKey         : alconpc_ace-sx-b2b_AYfj_xl-fljaPvznLEc0
         [echo] - sonar.projectVersion     : 1.0
         [echo] - sonar.additionalModules  : 
         [echo] - sonar.extensions.clean   : alconbackoffice,alconfacades,alconcore,alconocc,alconfulfilmentprocess,alconinitialdata,alconintegration,
         [echo] - sonar.excludedExtensions : 
         [echo] - sonar.exclusions         : /jalo/,/constants/,/*Standalone.java,/.js,**/.css,/*.xml,/.jsp,**/.less,**/*.xsd
         [echo] - sonar.projectBaseDir     : /var/jenkins/workspace/ace-sx-b2b_PR-1773/hybris/bin
         [echo] - sonar.junit.reportPaths  : 
         [echo] - sonar.coverage.jacoco.xmlReportPaths : /var/jenkins/workspace/ace-sx-b2b_PR-1773/reports.xml
         [echo] ******************************************************************
    ...
    [sonar:sonar] Load branch configuration
    [sonar:sonar] Found manual configuration of branch/PR analysis. Skipping automatic configuration.
    [sonar:sonar] Load branch configuration (done) | time=8ms
    
  • You are using the Sonar Scanner for Ant, which is actually deprecated. After you fix your PR decoration issue, I recommend you switch over to the Sonar Scanner CLI as mentioned in this announcement “SonarScanner for Ant” is deprecated .

Here is what you need to do next:

  1. Remove any references to sonar.branch.* and sonar.pullrequest.* analysis parameters in your sonarcheck Ant task and Jenkinsfile and anywhere else you trying to set these parameters manually. Do not do that. Let the Jenkins SonarQube plugin handle that.
  2. In the Jenkins job for your project > Branch Sources section, double-check how you set Discover pull requests from forks and Specify ref specs as my screenshot above shows. You need to match what I have.

If you still have trouble, please provide the following:

  1. Your build.xml file that shows your sonarcheck task.
  2. Your Jenkinsfile
  3. Screenshot of your Branch Sources section of your Jenkins job for this project
  4. DEBUG Jenkins logs





I have attached multibranch pipeline configuration.
along with I have raise PR request with sonar configuration of pullrequest which you suggested. Please let me know whether those changes would be fine.

we have to provide Branch name in Sonar properties file manually, please correct me if I m wrong

Hi @ashishb ,

Thanks for the screenshots, very helpful! I see your Jenkins multibranch pipeline looks good.

The last screenshot shows you defining pullrequest parameters. Are those used by sonarcheck task? As I mentioned earlier:

  1. Remove any references to sonar.branch.* and sonar.pullrequest.* analysis parameters in your sonarcheck Ant task and Jenkinsfile and anywhere else you trying to set these parameters manually. Do not do that. Let the Jenkins SonarQube plugin handle that.

So to answer your doubt here:

No, that is incorrect. Do not define any sonar.branch.* and sonar.pullrequest.* parameters manually.

If you still have trouble, please provide the following:

  1. Your build.xml file that shows your sonarcheck task.
  2. Your Jenkinsfile
  3. DEBUG Jenkins log

Hi Joe


No, those changes are yet not updated of attached screenshot. Still pending for approval. Not used by sonarcheck task.
I have verified sonar.branch.* and sonar.pullrequest.* not configured manually.

Shall I execute below command like below or simply shall i execute as “sh “. ./setantenv.sh && ant clean all && ant sonarcheck””
sh “. ./setantenv.sh && ant clean all && ant -Dpull.request.number=${PULL_REQUEST_NUMBER} -Dpull.request.branch=${PULL_REQUEST_BRANCH} -Dpull.request.base=${PULL_REQUEST_BASE} sonarcheck”

Hello Ashish,

Ok good, that’s what we want: no sonar.branch.* and sonar.pullrequest.* parameters defined when using the SonarQube Jenkins plugin.

That looks ok, but the problem is that your sonarcheck is somehow defining sonar.branch.* or sonar.pullrequest.* somehow, which it should not.

Please provide the following:

  1. Your build.xml file that shows your sonarcheck task.
  2. Your Jenkinsfile
  3. DEBUG Jenkins log when you attempt running that above sh command.

Hi Joe
please find the Build.xml and Jenkinsfile
i will share DEBUG JENKINS logs once PR runs
build.xml-file.log (23.4 KB)

please rename build.xml-file.log to build.xml
Jenkinsfile.txt (1.6 KB)
I will upload PR DEBUG jenkins log once it get executed.

Hello,

I want to emphasize again that Sonar Scanner for Ant is now deprecated, and I think it’s best you switch over to using just the Sonar Scanner CLI instead. Instructions on how to migrate are here: SonarScanner for Ant

From your Jenkinsfile, I still see you defining sonar.branch.name. You should not define that. Is there some reason you need it for hybris/config/local.properties?

sh 'echo "sonar.branch.name=${BRANCH_NAME}" >>  hybris/config/local.properties'

I will await your logs to see the result of your recent changes.

Hi Joe
Thanks for your response.
BRANCH_NAME basically we are assigning branch name as part Build job , the branch on which job will be building.
Will it impact if we remove sonar.branch.name from our sonarproperties file?

Which sonarproperties file are you speaking of? Your local.properties file? Can you show what’s in that file? You can remove sonar.branch.name from there since SonarQube Jenkins plugin will handle that.

hi Joe
i m referring same local.properties file

Hi Joe
I found sonar.* values in sonar.xml and other files, its log has been attached. Kindly suggest.
soanr.txt (7.0 KB)

Thanks for the info. There seems to be only one place to clean:

bin/platform/resources/ant/sonar.xml:            <echo level="info" message="- Executing sonarcheck"/>
bin/platform/resources/ant/sonar.xml:                <isset property="sonar.branch.name"/>
bin/platform/resources/ant/sonar.xml:                    <echo level="info" message="- sonar.branch.name        : ${sonar.branch.name}"/>

Please delete any reference to sonar.branch.name.