ci: add sonar config

This commit is contained in:
CaptainB 2023-10-07 09:58:31 +08:00 committed by 刘瑞斌
parent 5a1c9627d7
commit 0a7cc79664
2 changed files with 50 additions and 1 deletions

37
.github/workflows/sonar.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: SonarCloud
on:
push:
branches:
- v2.10
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud 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 and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=metersphere_metersphere

14
pom.xml
View File

@ -89,7 +89,9 @@
<skipAntRunForJenkins>false</skipAntRunForJenkins>
<commons-dbcp2-version>2.9.0</commons-dbcp2-version>
<jgit-version>6.7.0.202309050840-r</jgit-version>
<!-- sonar -->
<sonar.organization>metersphere</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<modules>
@ -184,4 +186,14 @@
<url>https://repository.fit2cloud.com/content/repositories/fit2cloud-public</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>fit2cloud-public</id>
<url>https://repository.fit2cloud.com/repository/public/</url>
</repository>
</repositories>
</project>