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.
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:
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:
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.
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:
Your build.xml file that shows your sonarcheck task.
Your Jenkinsfile
Screenshot of your Branch Sources section of your Jenkins job for this project
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
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:
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:
Your build.xml file that shows your sonarcheck task.
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”
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.