Skip to content

Setup Scanner CLI for SonarQube (Server, Cloud)

Actions

About

GitHub Actions to setup Scanner CLI for SonarQube (Server, Cloud) and add it to PATH
v1.3.0
Latest
Star (5)

Setup SonarQube Scanner Action

Conventional Branch Conventional Commits SemVer

CI Check dist/

Coverage CodeQL GitHub Super-Linter

This Action sets up the Scanner CLI for SonarQube (Server, Cloud) for use in actions by:

  • Optionally downloading and caching distribution of the requested Scanner CLI version, and adding it to the PATH
  • Registering problem matchers for error output.

version can be the latest, an explicit or a semantic version range

You can find source code of the Scanner CLI here

Requirements

  • Node.js 20.19.0 or later (>=20.19.0).
  • GitHub-hosted runners are supported and follow GitHub runtime evolution.

Usage

Minimal (default use the latest version)

- uses: SylvainDumas/setup-sonar-scanner@v1

With an explicit version

- uses: SylvainDumas/setup-sonar-scanner@v1
  with:
    version: '8.0.1.6346'

With a semantic version range

- uses: SylvainDumas/setup-sonar-scanner@v1
  with:
    version: '8.x'

Tip

You can use expression like 7.x or more complex like >=1.2.7 <1.3.0, 1.2.7 || >=1.2.9 <2.0.0, ...

Inputs

version

Warning

Minimum version supported: 3.x

Full Example usage

You can find additional informations in official SonarQube documentation.

name: SonarQube Workflow

on:
  push:
    branches:
      - main # the name of your main branch
  pull_request:
    types: [opened, synchronize, reopened]

permissions:
  contents: read

jobs:
  sonarqube-analysis:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
      # Setup sonar-scanner
      - name: Setup SonarQube
        uses: SylvainDumas/setup-sonar-scanner@v1
      # Run sonar-scanner
      - name: SonarQube Scan
        run: sonar-scanner
          -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }}
          -Dsonar.token=${{ secrets.SONAR_TOKEN }}
          -Dsonar.organization=$GITHUB_REPOSITORY_OWNER
          -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}

Note

Need to be adapted following your use cases (GitHub workflow permissions, test coverage generation, ...)

Other actions

License

The scripts and documentation in this project are released under the MIT License

Setup Scanner CLI for SonarQube (Server, Cloud) is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

GitHub Actions to setup Scanner CLI for SonarQube (Server, Cloud) and add it to PATH
v1.3.0
Latest

Setup Scanner CLI for SonarQube (Server, Cloud) is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.