mirror of
https://github.com/SonarSource/sonarqube-quality-gate-action.git
synced 2026-10-05 19:31:31 +00:00
SQQGGHA-9 Use new SonarQube (Server, Cloud) product names
This commit is contained in:
1 parent
07d1da262a
commit
424137db1f
6 files changed
+17
-18
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
# SonarQube Quality Gate check [](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml)
|
# SonarQube Server Quality Gate check [](https://github.com/SonarSource/sonarqube-quality-gate-action/actions/workflows/run-qa.yml)
|
||||||
|
|
||||||
Check the Quality Gate of your code with [SonarQube](https://www.sonarqube.org/) to ensure your code meets your own quality standards before you release or deploy new features.
|
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.
|
||||||
|
|
||||||
<img src="./images/SonarQube-72px.png">
|
<img src="./images/SonarQubeServer.png">
|
||||||
|
|
||||||
SonarQube 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.
|
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.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -36,14 +36,14 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
|
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
|
||||||
- name: SonarQube Scan
|
- name: SonarQube Server Scan
|
||||||
uses: sonarsource/sonarqube-scan-action@master
|
uses: sonarsource/sonarqube-scan-action@master
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||||
|
|
||||||
# Check the Quality Gate status.
|
# Check the Quality Gate status.
|
||||||
- name: SonarQube Quality Gate check
|
- name: SonarQube Server Quality Gate check
|
||||||
id: sonarqube-quality-gate-check
|
id: sonarqube-quality-gate-check
|
||||||
uses: sonarsource/sonarqube-quality-gate-action@master
|
uses: sonarsource/sonarqube-quality-gate-action@master
|
||||||
with:
|
with:
|
||||||
@@ -54,9 +54,8 @@ jobs:
|
|||||||
|
|
||||||
# Optionally you can use the output from the Quality Gate in another step.
|
# Optionally you can use the output from the Quality Gate in another step.
|
||||||
# The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
|
# The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
|
||||||
- name: "Example show SonarQube Quality Gate Status value"
|
- name: "Example show SonarQube Server Quality Gate Status value"
|
||||||
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
|
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@@ -72,7 +71,7 @@ Typically, report metadata file for different scanners can vary and can be locat
|
|||||||
Example usage:
|
Example usage:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: SonarQube Quality Gate check
|
- name: SonarQube Server Quality Gate check
|
||||||
uses: sonarsource/sonarqube-quality-gate-action@master
|
uses: sonarsource/sonarqube-quality-gate-action@master
|
||||||
with:
|
with:
|
||||||
scanMetadataReportFile: target/sonar/report-task.txt
|
scanMetadataReportFile: target/sonar/report-task.txt
|
||||||
@@ -80,11 +79,11 @@ Example usage:
|
|||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
- `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).
|
- `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).
|
||||||
|
|
||||||
- `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).
|
- `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).
|
||||||
|
|
||||||
- `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).
|
- `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).
|
||||||
|
|
||||||
## Quality Gate check run
|
## Quality Gate check run
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
name: SonarQube Quality Gate Check
|
name: SonarQube Server Quality Gate Check
|
||||||
description: >
|
description: >
|
||||||
Check if a project / analysis passed the Quality Gate check
|
Check if a project / analysis passed the Quality Gate check
|
||||||
branding:
|
branding:
|
||||||
@@ -16,7 +16,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: .scannerwork/report-task.txt
|
default: .scannerwork/report-task.txt
|
||||||
pollingTimeoutSec:
|
pollingTimeoutSec:
|
||||||
description: "The maximum time (in seconds) to poll for SonarQube's Quality Gate status. Default: 300."
|
description: "The maximum time (in seconds) to poll for SonarQube Server's Quality Gate status. Default: 300."
|
||||||
required: false
|
required: false
|
||||||
default: "300"
|
default: "300"
|
||||||
outputs:
|
outputs:
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
@@ -55,7 +55,7 @@ done
|
|||||||
printf '\n'
|
printf '\n'
|
||||||
|
|
||||||
if [[ ${status} == "PENDING" || ${status} == "IN_PROGRESS" ]] && [[ ${SECONDS} -ge ${endTime} ]]; then
|
if [[ ${status} == "PENDING" || ${status} == "IN_PROGRESS" ]] && [[ ${SECONDS} -ge ${endTime} ]]; then
|
||||||
echo "Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube's Quality Gate."
|
echo "Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube Server's Quality Gate."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -77,6 +77,6 @@ elif [[ ${qualityGateStatus} == "ERROR" ]]; then
|
|||||||
fail "Quality Gate has FAILED.${reset}\n\n${analysisResultMsg}"
|
fail "Quality Gate has FAILED.${reset}\n\n${analysisResultMsg}"
|
||||||
else
|
else
|
||||||
set_output "quality-gate-status" "FAILED"
|
set_output "quality-gate-status" "FAILED"
|
||||||
fail "Quality Gate not set for the project. Please configure the Quality Gate in SonarQube or remove sonarqube-quality-gate action from the workflow."
|
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."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ teardown() {
|
|||||||
|
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "${github_out_actual}" = "quality-gate-status=FAILED" ]]
|
[[ "${github_out_actual}" = "quality-gate-status=FAILED" ]]
|
||||||
[[ "$output" = *"Quality Gate not set for the project. Please configure the Quality Gate in SonarQube or remove sonarqube-quality-gate action from the workflow."* ]]
|
[[ "$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."* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "fail when polling timeout is reached" {
|
@test "fail when polling timeout is reached" {
|
||||||
@@ -119,7 +119,7 @@ teardown() {
|
|||||||
run script/check-quality-gate.sh metadata_tmp 5
|
run script/check-quality-gate.sh metadata_tmp 5
|
||||||
|
|
||||||
[ "$status" -eq 1 ]
|
[ "$status" -eq 1 ]
|
||||||
[[ "$output" = *"Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube's Quality Gate."* ]]
|
[[ "$output" = *"Polling timeout reached for waiting for finishing of the Sonar scan! Aborting the check for SonarQube Server's Quality Gate."* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "fail when Quality Gate status WARN" {
|
@test "fail when Quality Gate status WARN" {
|
||||||
|
|||||||
Reference in new issue
Block a user