Skip to content

Commit 36010c5

Browse files
Add Sonar analysis to repository
1 parent f1f78b2 commit 36010c5

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,36 @@ jobs:
2525
- uses: jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
2626
with:
2727
version: 2025.7.12
28+
2829
- name: get secrets
2930
id: secrets
3031
uses: SonarSource/vault-action-wrapper@v3
3132
with:
3233
secrets: |
3334
development/kv/data/develocity token | DEVELOCITY_TOKEN;
3435
35-
# The SonarSource/ci-github-actions/build-gradle fails because of no access to ARTIFACTORY_DEPLOY_USERNAME
36-
# it is not needed in this case, so the Gradle is called directly
37-
- name: Build with Gradle
36+
- name: Create Gradle User Home
37+
shell: bash
38+
run: |
39+
export GRADLE_USER_HOME=${GITHUB_WORKSPACE}/.gradle
40+
mkdir -p ${GRADLE_USER_HOME}
41+
echo "GRADLE_USER_HOME=${GRADLE_USER_HOME}" >> $GITHUB_ENV
42+
export TODAY=$(date '+%Y-%m-%d')
43+
echo "TODAY=${TODAY}" >> $GITHUB_ENV
44+
find . -name '*.gradle.kts' -type f -exec md5sum {} \; | sort && md5sum gradle/libs.versions.toml && md5sum gradle/wrapper/gradle-wrapper.properties && md5sum gradle.properties > gradle-md5-sums.txt
45+
export GRADLE_CACHE_KEY=$(md5sum gradle-md5-sums.txt | awk '{ print $1 }')
46+
echo "GRADLE_CACHE_KEY=${GRADLE_CACHE_KEY}" >> $GITHUB_ENV
47+
rm gradle-md5-sums.txt
48+
- name: Cache Gradle Dependencies
49+
uses: SonarSource/ci-github-actions/cache@v1
50+
with:
51+
path: ${{ env.GRADLE_USER_HOME }}
52+
key: gradle-${{ env.GRADLE_CACHE_KEY }}
53+
54+
- uses: SonarSource/ci-github-actions/build-gradle@v1
3855
env:
3956
DEVELOCITY_ACCESS_KEY: develocity-public.sonar.build=${{ fromJSON(steps.secrets.outputs.vault).DEVELOCITY_TOKEN }}
40-
run: |
41-
./gradlew build
57+
with:
58+
deploy: false
59+
use-develocity: true
60+
artifactory-reader-role: private-reader

build.gradle.kts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* SonarSource Cloud Native Gradle Modules
3+
* Copyright (C) 2024-2025 SonarSource Sàrl
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource Sàrl.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the Sonar Source-Available License for more details.
13+
*
14+
* You should have received a copy of the Sonar Source-Available License
15+
* along with this program; if not, see https://sonarsource.com/license/ssal/
16+
*/
17+
plugins {
18+
id("org.sonarqube") version "7.2.0.6526"
19+
}
20+
21+
sonar {
22+
properties {
23+
property("sonar.projectKey", "SonarSource_cloud-native-gradle-modules")
24+
property("sonar.organization", "sonarsource")
25+
}
26+
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
group=org.sonarsource.cloudnative.gradle
2+
version=1.0-SNAPSHOT
3+
description=Common Gradle modules for multiple projects
4+
projectTitle=Cloud Security Gradle Modules
15
org.gradle.caching=true
26

37
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m

0 commit comments

Comments
 (0)