Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

Install SonarQube scanner

Actions
A GitHub Action to install sonarscanner with java, in a platform agnostic way
v1-beta2
Pre-release
Star (0)

Install SonarQube Scanner

GitHub

Description

This GitHub Action installs the SonarQube scanner along with Java in a platform-agnostic way. It's designed to help seamlessly integrate SonarQube's static code analysis tools into your CI/CD pipeline.

Why?

Well, the default sonarqube action (sonarsource/sonarqube-scan-action) uses a Dockerfile image. That is not bad in itself, but:

  • It's not completely platform agnostic, as it requires a container runtime in the github runner. We are avoiding that in our windows runners.
  • It builds every time you run the action, which we consider particularly wasteful. Also, you'll more often than not will hit the Docker Hub rate limit and your builds will fail.

Is it perfect? Not really. Now you will have to issue the sonar-scanner command yourself, which is a bit of a hassle.

Author

  • NOS Inovação

Inputs

Name Description Required Default
version The version of the SonarQube scanner to be used No 6.1.0.4477
javaDistribution The distribution of Java to be used No temurin
javaVersion The version of Java to be used No 21

Usage

To use this action in your workflow, add the following step to your GitHub Actions configuration file (.yml):

name: CI
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Install SonarQube scanner
      uses: nosinovacao/sonarscanner-action@v1
      with:
        version: '6.1.0.4477' # Specify the version if needed
        javaDistribution: 'temurin' # Specify the Java distribution
        javaVersion: '21'    # Specify the Java version

Then you can use the SonarQube scanner in your workflow by running sonar-scanner in your project's root directory.

    - name: Run SonarQube Scanner begin
      run: sonar-scanner begin -Dsonar.host.url=${{ secrets.SONARQUBE_URL }} -Dsonar.token=${{ secrets.SONARQUBE_TOKEN }} # etc…
    - name: build
      run: #run your build and tests and whatnot
    - name: Run SonarQube Scanner end and upload results
      run: sonar-scanner end

Steps

  • Set up JDK: If the installJava input is set to true, this step will install the specified Java distribution and version using the actions/setup-java action.

  • Set up SonarQube scanner: This step downloads and unzips the SonarQube scanner to /tmp and adds its path to the system by appending it to $GITHUB_PATH.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Install SonarQube scanner 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

A GitHub Action to install sonarscanner with java, in a platform agnostic way
v1-beta2
Pre-release

Install SonarQube scanner 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.