You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
SonarQube Quality Gate Report
v1.4.3
Check quality gate result from latest analysis and report result in the pull request's comment.
parameter | description | required | default |
---|---|---|---|
sonar-project-key | SonarQube project key | true |
|
sonar-host-url | SonarQube server URL | true |
|
sonar-token | SonarQube token for retrieving quality gate result | true |
|
github-token | GitHub Token for commenting on the pull request - not required if disable-pr-comment is set to true |
false |
|
disable-pr-comment | Disable commenting result on the pull request | false |
false |
fail-on-quality-gate-error | Set the action status to failed when quality gate status is ERROR |
false |
false |
branch | Branch name to retrieve the quality gate result | false |
parameter | description |
---|---|
project-status | Project's quality gate status either as OK or ERROR |
quality-gate-result | Quality gate of the latest analysis in JSON format |
name: Check quality gate result on pull request
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: phwt/sonarqube-quality-gate-action@v1
id: quality-gate-check
with:
sonar-project-key: ${{ secrets.SONAR_PROJECT_KEY }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: main # Optional input
- name: Output result
run: |
echo "${{ steps.quality-gate-check.outputs.project-status }}"
echo "${{ steps.quality-gate-check.outputs.quality-gate-result }}"
Sometimes the results will not be available right away after the scan has finished. Make sure to add a defer step before retrieving the scan results.
name: Check quality gate result on pull request
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: some/scan-actions@v1 # Step for scanning your project
- name: Wait for the quality gate result
run: sleep 5
- uses: phwt/sonarqube-quality-gate-action@v1
id: quality-gate-check
with:
sonar-project-key: ${{ secrets.SONAR_PROJECT_KEY }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: main # Optional input
- name: Output result
run: |
echo "${{ steps.quality-gate-check.outputs.project-status }}"
echo "${{ steps.quality-gate-check.outputs.quality-gate-result }}"