|
1 |
| -name: SonarQube Scan |
| 1 | +name: Build |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
|
9 | 9 | - '**'
|
10 | 10 |
|
11 | 11 | jobs:
|
12 |
| - sonarQube: |
| 12 | + build: |
| 13 | + name: Build and analyze |
13 | 14 | runs-on: ubuntu-latest
|
14 | 15 |
|
15 | 16 | steps:
|
16 |
| - - name: Checkout repository |
17 |
| - uses: actions/checkout@v2 |
18 |
| - |
19 |
| - - name: Set up JDK 22 |
20 |
| - uses: actions/setup-java@v2 |
21 |
| - with: |
22 |
| - java-version: '22' |
23 |
| - |
24 |
| - - name: Cache SonarQube packages |
25 |
| - uses: actions/cache@v2 |
26 |
| - with: |
27 |
| - path: ~/.sonar/cache |
28 |
| - key: ${{ runner.os }}-sonar-cache |
29 |
| - restore-keys: | |
30 |
| - ${{ runner.os }}-sonar-cache |
31 |
| -
|
32 |
| - - name: SonarQube Scan |
33 |
| - env: |
34 |
| - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
35 |
| - run: mvn clean verify sonar:sonar -Dsonar.projectKey=<your_project_key> -Dsonar.host.url=<your_sonarqube_server_url> -Dsonar.login=${{ secrets.SONAR_TOKEN }} |
36 |
| - |
37 |
| - - name: Upload SonarQube results |
38 |
| - if: always() |
39 |
| - run: | |
40 |
| - echo "Uploading SonarQube results" |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 20 | + - name: Set up JDK 22 |
| 21 | + uses: actions/setup-java@v2 |
| 22 | + with: |
| 23 | + distribution: 'temurin' # or 'adopt', depending on your preference |
| 24 | + java-version: '22' |
| 25 | + - name: Cache SonarQube packages |
| 26 | + uses: actions/cache@v1 |
| 27 | + with: |
| 28 | + path: ~/.sonar/cache |
| 29 | + key: ${{ runner.os }}-sonar |
| 30 | + restore-keys: ${{ runner.os }}-sonar |
| 31 | + - name: Cache Maven packages |
| 32 | + uses: actions/cache@v1 |
| 33 | + with: |
| 34 | + path: ~/.m2 |
| 35 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 36 | + restore-keys: ${{ runner.os }}-m2 |
| 37 | + - name: Build and analyze |
| 38 | + env: |
| 39 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 40 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |
| 41 | + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=com.kafka.learn:kafkaStudy -Dsonar.projectName='KafkaStudy' |
0 commit comments