Giter Club home page Giter Club logo

sonarqube-quality-gate-action's Introduction

SonarQube Quality Gate Check

Quality Gate Status

Check quality gate result from latest analysis and report result in the pull request's comment.

PR comment

Inputs

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

Outputs

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

Usage example

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 }}"

Check the results immediately after the scan

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 }}"

sonarqube-quality-gate-action's People

Contributors

dependabot[bot] avatar nfinished avatar phwt avatar steffen-bach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sonarqube-quality-gate-action's Issues

Report URL does not point to a branch when `branch` is specified

  • Current behavior: The link for "View on SonarQube" in the comment always points to https://hosturl/dashboard?id=project-key regardless of the value in the branch input.
  • Expected behavior: The link for "View on SonarQube" in the comment should point to https://hosturl/dashboard?id=project-key&branch=name when branch input is specified.

const projectURL = trimTrailingSlash(hostURL) + `/dashboard?id=${projectKey}`;

[View on SonarQube](${projectURL})

Unable To Find the Image from the Build Step When Running in Self-Hosted Runner

Run phwt/sonarqube-quality-gate-action@v1
  with:
    sonar-project-key: Flowcontrol_Article_Module
    sonar-host-url: ***
    sonar-token: ***
    github-token: ***
    disable-pr-comment: false
    fail-on-quality-gate-error: false
  env:
    JAVA_HOME: /home/flowcontrol/Desktop/runners/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/18.0.[2](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:2)-101/x64
    JAVA_HOME_18_X64: /home/flowcontrol/Desktop/runners/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/18.0.2-101/x64
/usr/local/bin/docker run --name ac126852e5e4ae0cf54a70b8afdce58[3](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:3)3[4](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:4)[5](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:5)959_de[6](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:6)3e5 --label ac1268 --workdir /github/workspace --rm -e "JAVA_HOME" -e "JAVA_HOME_18_X64" -e "INPUT_SONAR-PROJECT-KEY" -e "INPUT_SONAR-HOST-URL" -e "INPUT_SONAR-TOKEN" -e "INPUT_GITHUB-TOKEN" -e "INPUT_DISABLE-PR-COMMENT" -e "INPUT_FAIL-ON-QUALITY-GATE-ERROR" -e "INPUT_BRANCH" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/flowcontrol/Desktop/runners/actions-runner/_work/_temp/_github_home":"/github/home" -v "/home/flowcontrol/Desktop/runners/actions-runner/_work/_temp/_github_workflow":"/github/workflow" -v "/home/flowcontrol/Desktop/runners/actions-runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/flowcontrol/Desktop/runners/actions-runner/_work/RP-Flowcontrol/RP-Flowcontrol":"/github/workspace" ac1268:52e5e4ae0cf54a[7](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:7)0b[8](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:8)afdce583345[9](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:9)59
Unable to find image 'ac[12](https://github.com/rikp777/RP-Flowcontrol/actions/runs/8326066021/job/22781091312#step:13:13)68:52e5e4ae0cf54a70b8afdce583345959' locally
docker: Error response from daemon: pull access denied for ac1268, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.