Skip to content

Commit

Permalink
fix sonar build
Browse files Browse the repository at this point in the history
  • Loading branch information
itsankit-google committed Aug 5, 2024
1 parent dd4812e commit 82c962c
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/build-sonar-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,27 @@ jobs:
run-id: ${{ github.event.workflow_run.id }}
path: artifacts/

- name: Validate PR
id: validate_pr
- name: Sonar Report on PR
# For whatever reason we get PR 69 for develop branch with both head and base as develop.
if: ${{ github.event.workflow_run.pull_requests[0].head.ref != github.event.workflow_run.pull_requests[0].base.ref }}
run: |
PR_KEY=${{ github.event.workflow_run.pull_requests[0].number }}
PR_BRANCH=${{ github.event.workflow_run.pull_requests[0].head.ref }}
PR_BASE=${{ github.event.workflow_run.pull_requests[0].base.ref }}
echo "PR_KEY=$PR_KEY" >> $GITHUB_ENV
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV
echo "PR_BASE=$PR_BASE" >> $GITHUB_ENV
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: >-
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -fae -T 2 -B -V
-Dmaven.repo.local=$HOME/.m2/repository11
-DcloudBuild
-Pcoverage,templates
-Dmaven.wagon.http.retryHandler.count=3
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}
-Dsonar.branch.name=$BRANCH
- name: Sonar report
if: ${{ github.event.workflow_run.pull_requests[0].head.ref == github.event.workflow_run.pull_requests[0].base.ref }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
Expand All @@ -68,9 +76,6 @@ jobs:
-Pcoverage,templates
-Dmaven.wagon.http.retryHandler.count=3
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
-Dsonar.pullrequest.key=${{ env.PR_KEY }} \
-Dsonar.pullrequest.branch=${{ env.PR_BRANCH }} \
-Dsonar.pullrequest.base=${{ env.PR_BASE }} \
-Dsonar.branch.name=$BRANCH
- name: Surefire Report
Expand Down

0 comments on commit 82c962c

Please sign in to comment.