Skip to content

Commit 50ec854

Browse files
authored
Enable Develocity build scans (#866)
1 parent 3e2169a commit 50ec854

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939

4040
- name: Build
4141
run: ./gradlew clean check shadowJar
42+
env:
43+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
4244

4345
- run: java -cp sdk-usage/build/libs/opentelemetry-examples-sdk-usage-0.1.0-SNAPSHOT-all.jar io.opentelemetry.sdk.example.ConfigureSpanProcessorExample
4446

@@ -63,6 +65,8 @@ jobs:
6365
run: |
6466
export OTEL_EXPERIMENTAL_CONFIG_FILE=$(pwd)/otel-sdk-config.yaml
6567
../gradlew run
68+
env:
69+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
6670

6771
# this is not a required check to avoid blocking pull requests if external links break
6872
link-check:

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
# --no-daemon is required for codeql to observe the compilation
5656
# (see https://docs.github.com/en/code-security/codeql-cli/getting-started-with-the-codeql-cli/preparing-your-code-for-codeql-analysis#specifying-build-commands)
5757
run: ./gradlew assemble --no-build-cache --no-daemon
58+
env:
59+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
5860

5961
- name: Perform CodeQL analysis
6062
uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 # v4.30.9

settings.gradle.kts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,46 @@ plugins {
1414
id("com.gradle.develocity")
1515
}
1616

17+
val develocityServer = "https://develocity.opentelemetry.io"
18+
val isCI = System.getenv("CI") != null
19+
val develocityAccessKey = System.getenv("DEVELOCITY_ACCESS_KEY") ?: ""
20+
21+
// if develocity access key is not given and we are in CI, then we publish to scans.gradle.com
22+
val useScansGradleCom = isCI && develocityAccessKey.isEmpty()
23+
1724
develocity {
25+
if (useScansGradleCom) {
26+
buildScan {
27+
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
28+
termsOfUseAgree = "yes"
29+
}
30+
} else {
31+
server = develocityServer
32+
buildScan {
33+
publishing.onlyIf { it.isAuthenticated }
34+
}
35+
}
36+
1837
buildScan {
19-
publishing.onlyIf { System.getenv("CI") != null }
20-
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
21-
termsOfUseAgree.set("yes")
38+
uploadInBackground = !isCI
39+
40+
capture {
41+
fileFingerprints = true
42+
}
43+
44+
buildScanPublished {
45+
java.io.File("build-scan.txt").printWriter().use { writer ->
46+
writer.println(buildScanUri)
47+
}
48+
}
49+
}
50+
}
51+
52+
if (!useScansGradleCom) {
53+
buildCache {
54+
remote(develocity.buildCache) {
55+
isPush = isCI && develocityAccessKey.isNotEmpty()
56+
}
2257
}
2358
}
2459

0 commit comments

Comments
 (0)