-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 2.3 KB
/
Copy pathsonarcloud.yml
File metadata and controls
69 lines (60 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: SonarCloud Analysis
on:
push:
branches:
- main
- master
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Verify CI-based analysis is enabled
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
echo "Checking SonarCloud project settings..."
# Query project settings to check if automatic analysis is disabled
PROJECT_SETTINGS=$(curl -s -u "$SONAR_TOKEN:" \
"https://sonarcloud.io/api/settings/values?component=FlossWare_commons-java")
echo "Project settings retrieved. Proceeding with CI-based analysis..."
echo ""
echo "NOTE: If this workflow fails with 'Automatic Analysis is enabled',"
echo "you must manually disable it in the SonarCloud web UI:"
echo " 1. Visit: https://sonarcloud.io/project/administration/analysis_method?id=FlossWare_commons-java"
echo " 2. Select 'CI-based analysis'"
echo " 3. Disable 'Automatic Analysis'"
echo ""
- name: Build and analyze with SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONARCLOUD_SKIP_AUTOCONFIG: true
run: |
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=FlossWare_commons-java \
-Dsonar.organization=flossware \
-Dsonar.scanner.skipJreProvisioning=true \
-Dsonar.scanner.skip.autoscan=true \
-Dsonar.scm.disabled=false \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \
-Dsonar.qualitygate.wait=true