Skip to content

Commit

Permalink
cicd: set sonar scan to not specify the PR key if no number is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazrius committed Jul 10, 2023
1 parent e56274c commit 18a657a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ jobs:
- name: 'Unzip Artifacts'
run: |
Expand-Archive -Force sonar-build.zip ${{ env.BUILD_WRAPPER_OUT_DIR }}
Expand-Archive -Force pr-number.zip .
$number = Get-Content -Path pr-number.txt
echo "PR_NUMBER=$number" >> $env:GITHUB_ENV
if (Test-Path -Path pr-number.zip) {
Expand-Archive -Force pr-number.zip .
$number = Get-Content -Path pr-number.txt
echo "PR_NUMBER=$number" >> $env:GITHUB_ENV
}
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
Expand All @@ -72,4 +74,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.pullrequest.key="${{ env.PR_NUMBER }}" --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
if ($null -ne $env:PR_NUMBER) { sonar-scanner --define sonar.pullrequest.key="${{ env.PR_NUMBER }}" --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" }
else { sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" }

0 comments on commit 18a657a

Please sign in to comment.