Passing extra parameters to GitHub Action

Hi, I’m using GitHub Actions to do the analysis and I would like to pass in the version of the source code we are running the analysis for, to make tracking it back to the build and commit easier.

Is this already supported? I guess I can try updating the properties file before the run, but I would rather pass it into the run like any other sonar parameter. For example, I’ve tested it with this:

# SonarCloud integration
    - name: SonarCloud Scan
      uses: sonarsource/sonarcloud-github-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      with: 
        projectVersion: ${{ github.RUN_NUMBER }}

That’d be great. Any workaround to achieve that until we get this implemented?

It can be achieved with

- name: SonarCloud Scan
  uses: sonarsource/sonarcloud-github-action@master
  with:
    projectBaseDir: ./
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    BUILD_NUMBER: ${{ github.run_number }}

and sonar.projectVersion=${env.BUILD_NUMBER} in the sonar-project.properties

1 Like