We have a private GitHub repository to which we integrated with the sonarcloud-github-action plugin:
Somehow the pull requests are being reported on Sonar as pull requests, which is good, but Sonar is not reporting back through the Checks API.
We have other pipeline running on our private jenkins and these are reporting the Sonar Check properly on the PRs, so we are not sure what is missing from our side.
The workflow yaml is pretty simple:
- name: Environment
run: |
org="$(cut -d/ -f1 <<< "$GITHUB_REPOSITORY")"
repo="$(cut -d/ -f2 <<< "$GITHUB_REPOSITORY")"
echo "SONAR_ORGANIZATION=$org" >> "$GITHUB_ENV"
echo "SONAR_PROJECT_KEY=${org}_${repo}" >> "$GITHUB_ENV"
# When running in the sonar container the workspace is remapped
echo "WORKSPACE=/github/workspace" >> "$GITHUB_ENV"
- name: SonarCloud Scan
id: sonar
# https://github.com/SonarSource/sonarcloud-github-action
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
And our property file is very simple:
sonar.projectKey = ${env.SONAR_PROJECT_KEY}
sonar.organization = ${env.SONAR_ORGANIZATION}
sonar.pullrequest.provider = GitHub
sonar.pullrequest.github.repository = ${env.GITHUB_REPOSITORY}
sonar.projectBaseDir = .
sonar.sources = .
# sonar.tests = .
sonar.sourceEncoding = UTF-8
# Analysis Scope
# https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/
# https://sonarcloud.io/project/settings?category=exclusions&id=clumio_cdf
sonar.exclusions = \
**/vendor/**,\
**/.vendor-new/**
See attached screenshots since this is a private project.
PRs properly reported on SonarCloud:
No Sonar check on the Pull Request view in GitHub:
For reference the task if was AXYA11QT96rcPUGNOu8c
Our other repositories that use jenkins under the same GitHub and SonarCloud organization are properly reporting the Sonar Check int he Pull Requests so we know that SonarCloud is capable of reporting and the issue seems to be specific to GH Actions. Is there anything else we are missing?