Skip to content

Commit 5a8df80

Browse files
SQRP-122 Reference SonarQube Community Build (#61)
1 parent 2a53a0f commit 5a8df80

7 files changed

+23
-18
lines changed

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
# SonarQube Server Quality Gate check [![QA](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml/badge.svg)](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml)
1+
# SonarQube Quality Gate check [![QA](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml/badge.svg)](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml)
22

3-
Check the Quality Gate of your code with [SonarQube Server](https://www.sonarsource.com/products/sonarqube/) to ensure your code meets your own quality standards before you release or deploy new features.
3+
Check the Quality Gate of your code with [SonarQube Server](https://www.sonarsource.com/products/sonarqube/) or [SonarQube Community Build](https://www.sonarsource.com/open-source-editions/sonarqube-community-edition/) to ensure your code meets your own quality standards before you release or deploy new features.
44

5-
<img src="./images/SonarQubeServer.png">
5+
<picture>
6+
<source media="(prefers-color-scheme: dark)" srcset="./images/SonarQube_dark.png">
7+
<img alt="Logo" src="./images/SonarQube_light.png">
8+
</picture>
69

7-
SonarQube Server is the leading product for Continuous Code Quality & Code Security. It supports most popular programming languages, including Java, JavaScript, TypeScript, C#, Python, C, C++, and many more.
10+
[SonarQube Server](https://www.sonarsource.com/products/sonarqube/) and [SonarQube Community Build](https://www.sonarsource.com/open-source-editions/sonarqube-community-edition/) are widely used static analysis solutions for continuous code quality and security inspection.
11+
12+
They help developers detect coding issues in 30+ languages, frameworks, and IaC platforms, including Java, JavaScript, TypeScript, C#, Python, C, C++, and [many more](https://www.sonarsource.com/knowledge/languages/).
813

914
## Requirements
1015

1116
A previous step must have run an analysis on your code.
1217

13-
Read more information on how to analyze your code [here](https://docs.sonarqube.org/latest/analysis/github-integration/)
18+
Read more information on how to analyze your code for SonarQube Server [here](https://docs.sonarsource.com/sonarqube-server/latest/devops-platform-integration/github-integration/introduction/) and for SonarQube Community Build [here](https://docs.sonarsource.com/sonarqube-community-build/devops-platform-integration/github-integration/introduction/)
1419

1520
## Usage
1621

@@ -36,14 +41,14 @@ jobs:
3641
fetch-depth: 0
3742

3843
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
39-
- name: SonarQube Server Scan
44+
- name: SonarQube Scan
4045
uses: sonarsource/sonarqube-scan-action@master
4146
env:
4247
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4348
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
4449

4550
# Check the Quality Gate status.
46-
- name: SonarQube Server Quality Gate check
51+
- name: SonarQube Quality Gate check
4752
id: sonarqube-quality-gate-check
4853
uses: sonarsource/sonarqube-quality-gate-action@master
4954
with:
@@ -54,13 +59,13 @@ jobs:
5459

5560
# Optionally you can use the output from the Quality Gate in another step.
5661
# The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
57-
- name: "Example show SonarQube Server Quality Gate Status value"
62+
- name: "Example show SonarQube Quality Gate Status value"
5863
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
5964
```
6065
6166
Make sure to set up `pollingTimeoutSec` property in your step, to avoid wasting action minutes per month (see above example). If not provided, the default value of 300s is applied.
6267

63-
When using this action with [sonarsource/sonarqube-scan](https://github.com/SonarSource/sonarqube-scan-action) action or with [C/C++ code analysis](https://docs.sonarqube.org/latest/analysis/languages/cfamily/) you don't have to provide `scanMetadataReportFile` input, otherwise you should alter the location of it.
68+
When using this action with [sonarsource/sonarqube-scan](https://github.com/SonarSource/sonarqube-scan-action) action or with [C/C++ code analysis](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/languages/c-family/overview/) (available only for SonarQube Server) you don't have to provide `scanMetadataReportFile` input, otherwise you should alter the location of it.
6469

6570
Typically, report metadata file for different scanners can vary and can be located in:
6671

@@ -71,19 +76,19 @@ Typically, report metadata file for different scanners can vary and can be locat
7176
Example usage:
7277

7378
```yaml
74-
- name: SonarQube Server Quality Gate check
79+
- name: SonarQube Quality Gate check
7580
uses: sonarsource/sonarqube-quality-gate-action@master
7681
with:
7782
scanMetadataReportFile: target/sonar/report-task.txt
7883
```
7984

8085
### Environment variables
8186

82-
- `SONAR_TOKEN` – **Required** this is the token used to authenticate access to SonarQube Server. You can read more about security tokens [here](https://docs.sonarqube.org/latest/user-guide/user-token/). You can set the `SONAR_TOKEN` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
87+
- `SONAR_TOKEN` – **Required** this is the token used to authenticate access to SonarQube. You can read more about security tokens [here](https://docs.sonarqube.org/latest/user-guide/user-token/). You can set the `SONAR_TOKEN` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
8388

84-
- `SONAR_HOST_URL` – **Optional** this tells the scanner where SonarQube Server is hosted, otherwise it will get the one from the scan report. You can set the `SONAR_HOST_URL` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
89+
- `SONAR_HOST_URL` – **Optional** this tells the scanner where SonarQube is hosted, otherwise it will get the one from the scan report. You can set the `SONAR_HOST_URL` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
8590

86-
- `SONAR_ROOT_CERT` – Holds an additional root certificate (in PEM format) that is used to validate the SonarQube Server certificate. You can set the `SONAR_ROOT_CERT` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
91+
- `SONAR_ROOT_CERT` – Holds an additional root certificate (in PEM format) that is used to validate the SonarQube certificate. You can set the `SONAR_ROOT_CERT` environment variable in the "Secrets" settings page of your repository, or you can add them at the level of your GitHub organization (recommended).
8792

8893
## Quality Gate check run
8994

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ inputs:
1717
required: false
1818
default: .scannerwork/report-task.txt
1919
pollingTimeoutSec:
20-
description: "The maximum time (in seconds) to poll for SonarQube Server's Quality Gate status. Default: 300."
20+
description: "The maximum time (in seconds) to poll for SonarQube's Quality Gate status. Default: 300."
2121
required: false
2222
default: "300"
2323
outputs:

images/SonarQubeServer.png

-3.89 KB
Binary file not shown.

images/SonarQube_dark.png

5.92 KB
Loading

images/SonarQube_light.png

6.14 KB
Loading

script/check-quality-gate.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ done
5555
printf '\n'
5656

5757
if [[ ${status} == "PENDING" || ${status} == "IN_PROGRESS" ]] && [[ ${SECONDS} -ge ${endTime} ]]; then
58-
echo "Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube Server's Quality Gate."
58+
echo "Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube's Quality Gate."
5959
exit 1
6060
fi
6161

@@ -77,6 +77,6 @@ elif [[ ${qualityGateStatus} == "ERROR" ]]; then
7777
fail "Quality Gate has FAILED.${reset}\n\n${analysisResultMsg}"
7878
else
7979
set_output "quality-gate-status" "FAILED"
80-
fail "Quality Gate not set for the project. Please configure the Quality Gate in SonarQube Server or remove sonarqube-quality-gate action from the workflow."
80+
fail "Quality Gate not set for the project. Please configure the Quality Gate in SonarQube or remove sonarqube-quality-gate action from the workflow."
8181
fi
8282

test/check-quality-gate-test.bats

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ teardown() {
102102

103103
[ "$status" -eq 1 ]
104104
[[ "${github_out_actual}" = "quality-gate-status=FAILED" ]]
105-
[[ "$output" = *"Quality Gate not set for the project. Please configure the Quality Gate in SonarQube Server or remove sonarqube-quality-gate action from the workflow."* ]]
105+
[[ "$output" = *"Quality Gate not set for the project. Please configure the Quality Gate in SonarQube or remove sonarqube-quality-gate action from the workflow."* ]]
106106
}
107107

108108
@test "fail when polling timeout is reached" {
@@ -119,7 +119,7 @@ teardown() {
119119
run script/check-quality-gate.sh metadata_tmp 5
120120

121121
[ "$status" -eq 1 ]
122-
[[ "$output" = *"Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube Server's Quality Gate."* ]]
122+
[[ "$output" = *"Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube's Quality Gate."* ]]
123123
}
124124

125125
@test "fail when Quality Gate status WARN" {

0 commit comments

Comments
 (0)