-
Using the sonar cube action from here → https://github.com/SonarSource/sonarqube-scan-action which spins up a docker container and runs the sonar.
-
Version of sonarcube server = 8.6
-
SONAR Scanner = 4.7.0
-
Version of Java used by SONAR is Java 11
-
Github actions template workflow file
if: "!contains(github.event.head_commit.message, 'maven-release-plugin')"
name: Sonar Scan
runs-on: [ self-hosted]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- run: mvn package -Dmaven.test.skip=true -P my_profile -U -s settings.xml
- name: SonarQube Scan - PR
if: ${{ github.event_name == 'pull_request_target' }}
uses: sonarsource/sonarqube-scan-action@master
with:
args: >
-Dsonar.pullrequest.key=${{github.event.number}}
-Dsonar.pullrequest.branch=PR-${{github.event.number}}
-Dsonar.pullrequest.base=master
-Dsonar.working.directory=/tmpDir/${{github.sha}}/sonar
- name: SonarQube Scan - Push
if: ${{ github.event_name == 'push' }}
uses: sonarsource/sonarqube-scan-action@master
with:
args: >
-Dsonar.working.directory=/tmpDir/${{github.sha}}/sonar ```