sonar-scm-plugin
Usage
$ mvn sonar:sonar -Dsonar.projectKey=[PROJECT_KEY] -Dsonar.host.url=[SONAR_URL] -Dsonar.analysis.host=[REPO_HOST] -Dsonar.analysis.owner=[REPO_OWNER] -Dsonar.analysis.repo=[REPO_NAME] -Dsonar.analysis.pullNumber=[PR_NUMBER] -Dsonar.analysis.token=[GITHUB_ACCESS_TOKEN] -Dsonar.analysis.scm=[SCM] -Dsonar.analysis.username=[SCM_USERNAME] -Dsonar.login=[PROJECT_TOKEN]
Parameters
Parameter | Example | Description |
---|---|---|
sonar.projectKey 1/ |
test | Key of the SonarQube project |
sonar.host.url 1/ |
http://localhost:9000 | URL running the SonarQube instance |
sonar.login 1/ |
[PROJECT_TOKEN] | Token generated in SonarQube to access given project |
sonar.analysis.host |
https://api.github.com | Hostname of the analyzed SCM |
sonar.analysis.owner |
LZaruba | Owner of the repository, usually a part of the repo URL |
sonar.analysis.repo |
sonar-scm-plugin | Name of the repository |
sonar.analysis.pullNumber |
27 | #id of the pull request |
sonar.analysis.token |
[ACCESS_TOKEN] | Access token for the SCM |
sonar.analysis.scm |
github | Type of the SCM, valid values are github , bitbucketServer |
sonar.analysis.username |
LZaruba | Username related to the access token for the SCM |
1/ Properties related to the Maven SonarQube plugin, listed for reference only
Development and Contributing
Run Locally
- Build docker image:
$ make build
- Run sonarqube locally:
$ docker-compose up
# or to avoid attaching the volume use:
$ docker run -p 9000:9000 -p 8000:8000 docker.io/lz/sonar-scm-plugin
-
Init the SonarQube server
- Visit: http://localhost:9000
- Login using admin / admin credentials
- Update the admin password to any that you like
- Accept risk of installed plugin
- Create project using the
Manually
option, choose whatever name and key - Create token using
Locally
option when asked about: How do you want to analyze your repository? - Choose any name for the token
- Copy the generated token value
- Boom! Done!
-
Execute the Sonar analysis as described in the Usage section
Debugging
- Attach Remote Debug to
localhost:8000
(see IntelliJ Tutorial) - Set your breakpoints
- Execute Sonar analysis as described in the Usage section
- Wait for a bit once the analyzers are executed in SonarQube
- Debug...
Guidelines
- Follow the Google code style guide.
- Make sure that your change contain proper test coverage
- Separate API (Interface) from implementation (Class Implementation)
- Add license header and class header based on the example of
AnalysisProcessor
class