Update SonarQube project key and name in pom.xml #145
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| name: SonarQube Analyze | |
| on: | |
| push: | |
| branches: | |
| - '**' # This will trigger the workflow on pushes to any branch | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Cache SonarQube packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Build with Maven | |
| run: mvn -B clean package | |
| - name: Upload build output | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-output | |
| path: target/ | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Cache SonarQube packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Download build output | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-output | |
| path: target/ | |
| - name: Run tests | |
| run: mvn -B test | |
| analyze: | |
| name: SonarQube Analysis | |
| runs-on: ubuntu-latest | |
| needs: [build, test] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Cache SonarQube packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Download build output | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-output | |
| path: target/ | |
| - name: SonarQube Analysis | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| run: | | |
| mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ | |
| -Dsonar.javaOpts="-Xmx8192m " \ | |
| -Dsonar.scanner.debug="true" \ | |
| -Dsonar.sources="." \ | |
| -Dsonar.exclusions="src/test/java/**/*" \ | |
| -Dsonar.tests="src/test/java" \ | |
| -X | |
| - name: SonarQube Pull Request Analysis | |
| if: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| run: | | |
| mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ | |
| -Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ | |
| -Dsonar.pullrequest.base="${{ github.event.pull_request.base.ref }}" \ | |
| -Dsonar.pullrequest.branch="${{ github.head_ref }}" \ | |
| -Dsonar.javaOpts="-Xmx8192m " \ | |
| -Dsonar.scanner.debug="true" \ | |
| -Dsonar.sources="." \ | |
| -Dsonar.exclusions="src/test/java/**/*" \ | |
| -Dsonar.tests="src/test/java" \ | |
| -X |