Skip to content

Commit 3d1a427

Browse files
authored
Add sonarqube (#395)
* Add sonarqube * Update build-stubbornjava-web.yml * Update build.gradle * Update build.gradle * Update build-stubbornjava-web.yml * Update build-stubbornjava-web.yml * Update build-stubbornjava-web.yml
1 parent f34b73c commit 3d1a427

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

.github/workflows/build-stubbornjava-web.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
steps:
1717
- name: checkout
1818
uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis for Sonarqube
1921

2022
# https://github.com/rlespinasse/github-slug-action
2123
- name: Inject slug/short variables
@@ -58,10 +60,20 @@ jobs:
5860
path: ~/.gradle/caches
5961
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
6062

63+
- name: Cache SonarCloud packages
64+
uses: actions/cache@v1
65+
with:
66+
path: ~/.sonar/cache
67+
key: ${{ runner.os }}-sonar
68+
restore-keys: ${{ runner.os }}-sonar
69+
6170
- name: Grant execute permission for gradlew
6271
run: chmod +x gradlew
6372
- name: Build with Gradle
64-
run: ./gradlew build --no-daemon
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
75+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
76+
run: ./gradlew build sonarqube --no-daemon --info
6577

6678
- name: Login to GitHub Container Registry
6779
uses: docker/login-action@v1

build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// {{start:build}}
2-
buildscript {
3-
repositories {
4-
jcenter()
5-
}
6-
// buildscript dependencies can be used for build time plugins.
7-
dependencies {
8-
9-
}
2+
plugins {
3+
id "org.sonarqube" version "3.3"
104
}
115

126
// Include a gradle script that has all of our dependencies split out.
@@ -84,6 +78,14 @@ allprojects {
8478
}
8579
}
8680
}
81+
82+
sonarqube {
83+
properties {
84+
property "sonar.projectKey", "StubbornJava_StubbornJava"
85+
property "sonar.organization", "stubbornjava"
86+
property "sonar.host.url", "https://sonarcloud.io"
87+
}
88+
}
8789
// Maven Publish End
8890
}
8991
// {{end:build}}

0 commit comments

Comments
 (0)