- Install Sonar
- Install Community Branch Plugin
- Figure out compatible version of plugin with your installed sonar version
- Copy plugin URL from the release page
- Run below command at two directories
/opt/sonarqube/lib/common
and/opt/sonarqube/extensions/plugin
(assuming your sonarqube is installed at/opt/sonarqube
)wget <pluging release URL>
e.g.wget https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/tag/1.3.2
- Restart sonar server
systemctl restart sonar
- Access the sonar portal > Administration. You should see "Pull Request" option on left side tabs. This means plugin is installed properly.
- Create Github App as mentioned in this document
- Install above app on the repositories that you've created.
- Add app details in SonarQube PR plugin
- Administration > Configuration > General Settings
- On "Github" Settings
- Add client id, secret id from your Github App Page
- Add API URL. For enterprise it would be something like this
https://github.company.com/api/v3
- Add Web URL for Github
- On "Pull Request" Settings
- Set Provider "Github"
- Give app id, app name, and paste the secret key created during github app creation.
- On "Github" Settings
- Administration > Configuration > General Settings
- Manually run below command for your Java/maven project. For other project types, the parameters will be same
mvn -X sonar:sonar \
-Dsonar.host.url=<sonar-instance>:9000/ \
-Dsonar.github.endpoint=<github URL> \ # Example, https://github.company.com/api/v3/
-Dsonar.language=java \
-Dsonar.jacoco.reportMissing.force.zero=true \
-Dsonar.projectName=<Project Name> \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.pullrequest.base=develop \
-Dsonar.pullrequest.branch=SonarTest \
-Djavax.net.debug=all \
-Dsonar.pullrequest.key=13 \
-Dsonar.verbose=true \
-Dsonar.pullrequest.github.repository=<github org>/<github repo>
- Refer this link to automatically run this script when somebody creates the PR.