Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Latest commit

 

History

History
75 lines (51 loc) · 4.01 KB

README.md

File metadata and controls

75 lines (51 loc) · 4.01 KB

sonarscanner-buildkite-plugin

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

Getting Started

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 sent
  • SONARSCANNER_LOGIN - This is the Token used to authenticate back to the sonar host

You have two options on how to configure these variables:

  1. Pipeline configuration - See environment-variables for additional information
  2. 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.

Example: Basic

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

Example: Additional Flags

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

Configuration

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

Contributing

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.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Mozilla Public License Version 2.0 - see the LICENSE file for details