SonarQube scanner plugin for buildkite using their publically available Dockerhub CLI Image. The plugin will automatically detect if the running build is a Github PR, Feature branch or your default branch (main/master) and report relevant findings back to your configured host.
For additional information around how to utilize/configure sonarscanner refer to sonarscanner
There are two environment variables that have to be set in order for the plugin to function. These variables are listed below:
SONARSCANNER_HOST
- The place where the sonarscan results should be sentSONARSCANNER_LOGIN
- This is the Token used to authenticate back to the sonar host
You have two options on how to configure these variables:
- Pipeline configuration - See environment-variables for additional information
- AWS Parameter Store (assume buildkite agent has enough permissions for the following paths:
/buildkite/SONARSCANNER_HOST
and/buildkite/SONARSCANNER_LOGIN
)
Once this is done, then you are able to use the plugin.
The below example can be used to run the sonarscanner plugin whenever your pipeline is triggered. If you want to skip specific branches etc, then use buildkite agnostic syntax to not run the plugin.
steps:
- label: ":sonarqube: Running sonarscanner"
plugins:
- jack1902/sonarscanner#v1.0.0:
project_key: "PLACEHOLDER"
agents:
queue: default
steps:
- label: ":sonarqube: Running sonarscanner"
plugins:
- jack1902/sonarscanner#v1.0.0:
project_key: "PLACEHOLDER"
additional_flags:
- "-Dsonar.coverage.jacoco.xmlReportPaths=coverage.xml"
- "-Dsonar.tests='app/tests'"
agents:
queue: default
Option | Required | Type | Default | Description |
---|---|---|---|---|
project_key | Yes | string |
The project key used inside of sonarqube | |
additional_flags | No | list(string) |
Additional flags to pass directly to the sonarscan, see the documentation for an extensive list sonarscanner | |
debug | No | boolean |
Run the plugin in debug mode, useful for validating given flags that are being passed to the docker container | |
artifacts | No | list(string) |
use buildkite-agent artifact download for each of the given paths. Helpful when wanting test-coverage output within SonarQube |
Feel free to open issues
and open Pull Requests to fix any bugs or extend the feature set of this plugin for your terraform
use-case.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Jack - Initial work - jack1902
See also the list of contributors who participated in this project.
This project is licensed under the Mozilla Public License Version 2.0 - see the LICENSE file for details