From 82c962cef579985b514c1ecbd3ec276fb976a25a Mon Sep 17 00:00:00 2001 From: itsankit-google Date: Mon, 5 Aug 2024 10:55:46 +0000 Subject: [PATCH] fix sonar build --- .github/workflows/build-sonar-report.yml | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-sonar-report.yml b/.github/workflows/build-sonar-report.yml index 6d6d96b4122..219fec576c8 100644 --- a/.github/workflows/build-sonar-report.yml +++ b/.github/workflows/build-sonar-report.yml @@ -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 @@ -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