I’m using SonarQube Enterprise Edition version 8.4.1.35646.
I’m trying to achieve SonarQube integration with BitBucket for PR analysis and decorate PR in BitBucket itself i.e., We want SonarQube to automatically analyze the branch code from bitbucket and display the issues in Bitbucket Pull request itself.
To achieve this I tried the following configuration
We have generated a personal access token with admin credentials in BitBucket.
We configured this personal access token and bitbucket url in SonarQube >> Administration >> ALM Integrations
Clicked on + Icon at right side top to add a project then clicked on bitbucket >> System displayed all the repositories available in bit bucket
So i selected one of the repo and clicked on set up selected repository
Then system is showing the two options to analyse the repo i) With jenkin ii) Manually
I selected manullay and followed the process to analyse the branch with following commands
SonarScanner.MSBuild.exe begin /k:“ProjectName” /d:sonar.host.url=“http://xxx.xxx.x.xxx:9000” /d:sonar.login=“username” /d:sonar.password=“password”
MsBuild.exe" “D:\BUILDS\SampleProject.sln” /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login=“username” /d:sonar.password=“password”
Project Settings >> General Settings >> Pull Request Decoration >> verified whether the Configuration name, Project Key and Repository SLUG are correct or not
I did the above configurations but the following expectation is not reached
Branch analysis is not happening automatically when there is a change in code in Repository
Pull Requests are not displaying in Project Settings >> Branches & Pull Requests
If any new issues in PR those issues should be highlighted in BitBucket Pull request itself
Please let me know if I’m missing anything to achieve my expectations
Versions of Tools:
SonarQube >> Enterprise Edition & 8.4.1.35646 version
Sonar Scanner >> 4.4.0.2170
BitBucket >> 6.6.2
Target
I’m trying to automate the Pull Request Decoration
Configurations did So Far
We have generated a personal access token with admin credentials in BitBucket.
We configured this personal access token and bitbucket URL in SonarQube >> Administration >> ALM Integrations
Clicked on + Icon at right side top to add a project then clicked on bitbucket >> System displayed all the repositories available in the bit bucket
So I selected one of the repo and clicked on set up a selected repository
Then the system is showing the two options to analyze the repo i) With Jenkin ii) Manually
I selected manually and followed the process to analyze the branch with the following commands
C:{scannerpath}\sonar-scanner 4.4.0.2170\bin\sonar-scanner
-Dsonar.projectKey=projectKey
-Dsonar.branch.name=branchname
-Dsonar.projectName=projectName
-Dsonar.host.url=hosturl
-Dsonar.login=loginkey
Project Settings >> General Settings >> Pull Request Decoration >> configured the Configuration name, Project Key and Repository SLUG
Created a PR in bit bucket and ran the following command
C:{scannerpath}\sonar-scanner 4.4.0.2170\bin\sonar-scanner
-Dsonar.projectKey=projectKey
-Dsonar.projectName=projectName
-Dsonar.host.url=hostURL
-Dsonar.login=login
-Dsonar.password=password
-Dsonar.pullrequest.branch=feature/v8.13.4
-Dsonar.pullrequest.base=master
-Dsonar.pullrequest.key=285
-Dsonar.pullrequest.bitbucket.repository=giturl
-Dsonar.pullrequest.bitbucket.owner=bitbucketusername
I’m doing the analysis manually as above
Please suggest to me how we can achieve the automating the PR analysis and PR decoration.
For TeamCity I’m not sure what it means. For another CI I would say that it’s about the upgrades we’ve done to read PR/branch values directly from your environment & apply them as necessary to minimize the configuration for new jobs. Aaand to not break old jobs, if those things are configured manually then we don’t intervene.