If you are already running a centralized SonarQube instance, use this action to scan a Git repository with the SonarQube static analysis scanner. The data collected from the scans is available in your SonarQube reports, and the results are also displayed in the CloudBees platform analytics dashboards.
If you do not have SonarQube already installed, use the Scan with SonarQube bundled action instead. |
All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Prerequisites
To use the Scan with SonarQube action, you must declare all metadata in the file sonar-project.properties
in the base directory of your SonarQube Server instance.
You must include the location of the sources to be scanned in this metadata.
In the following sonar-project.properties
file example, the location of the sources to be analyzed is src
:
sonar.projectKey=example:project sonar.projectName=My Project sonar.projectVersion=1.0 sonar.sources=src sonar.tests=src/tests sonar.sourceEncoding=UTF-8
For more information, refer to the SonarQube analysis scope documentation.
Inputs
Input name | Data type | Required? | Description |
---|---|---|---|
|
String |
Yes |
The SonarQube server URL. |
|
String |
Required if |
The SonarQube access token. |
|
String |
Required if |
The SonarQube username. |
|
String |
Required if |
The SonarQube password. |
|
String |
No |
The language of your Git repository code base. Refer to Supported languages. |
Supported languages
Supported language | Input format |
---|---|
Go |
|
JavaScript |
|
Java |
|
PHP |
|
Python |
|
Usage examples
In the following example, a Sonarqube access token is used for authentication:
- name: Scan with SonarQube uses: https://github.com/cloudbees-io/sonarqube-sast-scan-code@v1 with: server-url: ${{ vars.SONARQUBE_SERVER_URL }} access-token: ${{ secrets.SONARQUBE_USER_TOKEN }} language: "LANGUAGE_JAVA"
In the following example, username and password credentials are used for authentication:
- name: Scan with SonarQube uses: https://github.com/cloudbees-io/sonarqube-sast-scan-code@v1 with: server-url: ${{ vars.SONARQUBE_SERVER_URL }} username: ${{ secrets.SONARQUBE_USERNAME }} password: ${{ secrets.SONARQUBE_PASSWORD }} language: "LANGUAGE_GO"