Skip to content

Commit 8263229

Browse files
committed
Sonar scan for User Service
1 parent d0cb3d7 commit 8263229

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

.github/workflows/SonarQube.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: SonarCloud scan for User Services
2+
on:
3+
workflow_call:
4+
secrets:
5+
SONAR_TOKEN:
6+
required: true
7+
jobs:
8+
sonar-cloud-scan:
9+
name: Build and analyze
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: 'zulu' # Alternative distribution options are available.
20+
- name: Cache SonarCloud packages
21+
uses: actions/cache@v3
22+
with:
23+
path: ~/.sonar/cache
24+
key: ${{ runner.os }}-sonar
25+
restore-keys: ${{ runner.os }}-sonar
26+
- name: Cache Maven packages
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.m2
30+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: ${{ runner.os }}-m2
32+
- name: Build and analyze
33+
env:
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=DevOps-Video-Sharing_UserService

.github/workflows/main.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ jobs:
2626
- name: Unit Tests
2727
run: mvn -B test --file pom.xml
2828

29-
# - name: SonarQube Scan
30-
# env:
31-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32-
# run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar \
33-
# -Dsonar.projectKey=devops-video-sharing \
34-
# -Dsonar.host.url=https://sonarcloud.io \
35-
# -Dsonar.login=${{ secrets.SONAR_TOKEN }}
29+
sonar-cloud-scan:
30+
needs: testing
31+
uses: ./.github/workflows/SonarQube.yaml
32+
secrets:
33+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3634

3735
build-image:
3836
needs: testing

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<description>Demo project for Spring Boot</description>
1616
<properties>
1717
<java.version>17</java.version>
18+
<sonar.organization>devops-video-sharing</sonar.organization>
19+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
1820
</properties>
1921
<dependencies>
2022
<dependency>

0 commit comments

Comments
 (0)