Skip to content

Commit

Permalink
CI/Build: Add Gradle Build Scans
Browse files Browse the repository at this point in the history
Gradle Build Scans, free of use, collect a lot of information about a Gradle build, including the actual output of failed test. This becomes quite convenient when inspecting test failures in CI and a lot of other information about Gradle builds.

[Example build scan](https://scans.gradle.com/s/jpuykotf4hac6)
  • Loading branch information
snazy committed Nov 25, 2024
1 parent 3c5d20e commit 4885d3b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,45 @@ dependencyResolutionManagement {
}

gradle.beforeProject { version = baseVersion }

plugins { id("com.gradle.develocity") version ("3.18.2") }

// Publish a build-scan automatically in CI, else only on demand.
develocity {
if (System.getenv("CI") != null) {
buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
// Add some potentially interesting information from the environment
listOf(
"GITHUB_ACTION_REPOSITORY",
"GITHUB_ACTOR",
"GITHUB_BASE_REF",
"GITHUB_HEAD_REF",
"GITHUB_JOB",
"GITHUB_REF",
"GITHUB_REPOSITORY",
"GITHUB_RUN_ID",
"GITHUB_RUN_NUMBER",
"GITHUB_SHA",
"GITHUB_WORKFLOW"
)
.forEach { e ->
val v = System.getenv(e)
if (v != null) {
value(e, v)
}
}
val ghUrl = System.getenv("GITHUB_SERVER_URL")
if (ghUrl != null) {
val ghRepo = System.getenv("GITHUB_REPOSITORY")
val ghRunId = System.getenv("GITHUB_RUN_ID")
link("Summary", "$ghUrl/$ghRepo/actions/runs/$ghRunId")
link("PRs", "$ghUrl/$ghRepo/pulls")
}
}
} else {
val isBuildScan = gradle.startParameter.isBuildScan
buildScan { publishing { onlyIf { isBuildScan } } }
}
}

0 comments on commit 4885d3b

Please sign in to comment.