fix: repair build scan config via Develocity plugin (opt-in)#460
Merged
Conversation
Build scans stopped working because the configuration in build.gradle.kts
used the legacy Gradle Enterprise API at the project level:
if (hasProperty("buildScan")) {
extensions.findByName("buildScan")?.withGroovyBuilder {
setProperty("termsOfServiceUrl", ...)
setProperty("termsOfServiceAgree", "yes")
}
}
On Gradle 9 the `--scan` flag auto-applies the Develocity plugin, which
(a) is a settings plugin, so there is no project-level `buildScan`
extension to find, and (b) renamed the properties to `termsOfUseUrl` /
`termsOfUseAgree`. The `?.` therefore silently no-ops and the terms are
never accepted, so scan publishing fails. Because the plugin was only
ever auto-applied by `--scan`, its API also shifted on every Gradle
wrapper bump - hence the intermittent breakage.
Apply `com.gradle.develocity` 4.4.3 explicitly in settings.gradle.kts
(deterministic across wrapper bumps) and configure it with the current
API. Keep it strictly opt-in: the terms are accepted and a scan is
published only when `-PbuildScan` is passed (e.g. from CI). Local and
contributor builds neither accept Gradle's terms of use nor upload any
environment data.
Remove the dead legacy block from build.gradle.kts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Develocity plugin is now applied explicitly and gates scan publishing on the `-PbuildScan` opt-in (publishing.onlyIf). Pass that property from CI so release builds keep publishing scans. `--scan` is dropped: it would force publishing even without the opt-in, which now fails because the terms of use are only accepted when `-PbuildScan` is set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f72ea4e to
d9930e3
Compare
Test Results1 084 tests 1 084 ✅ 47s ⏱️ Results for commit 8a20262. ♻️ This comment has been updated with latest results. |
The Develocity plugin rejects any value other than "yes" for
buildScan.termsOfUseAgree - setting "no" produces a hard error:
The buildScan extension 'termsOfUseAgree' value must be exactly the
string 'yes' (without quotes). The value given was 'no'.
This surfaced on a release build that still passed --scan (which forces
a publish attempt) without -PbuildScan. Set termsOfUseAgree only when
opted in; otherwise leave it unset so a stray --scan degrades to a soft
"terms not agreed" notice instead of failing configuration.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrates the broken build-scan configuration to the current Develocity plugin, applied explicitly in `settings.gradle.kts`, and keeps it strictly opt-in via `-PbuildScan`.
Why it was broken
The old config in `build.gradle.kts` used the legacy Gradle Enterprise API at the project level:
```kotlin
if (hasProperty("buildScan")) {
extensions.findByName("buildScan")?.withGroovyBuilder {
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
setProperty("termsOfServiceAgree", "yes")
}
}
```
On Gradle 9, `--scan` (used in `ci/release.Jenkinsfile`) auto-applies the Develocity plugin, which:
So the terms were never accepted and scan publishing failed. And because the plugin was only ever auto-applied by `--scan`, its DSL shifted on every wrapper bump (8.13 → 9.x), which is why it "breaks every so often."
What changed
```kotlin
val buildScanOptIn = providers.gradleProperty("buildScan").isPresent
develocity {
buildScan {
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
termsOfUseAgree = if (buildScanOptIn) "yes" else "no"
publishing.onlyIf { buildScanOptIn }
}
}
```
CI note
CI already passes `-PbuildScan` is not currently set — it relies on `--scan`. After this lands, pass `-PbuildScan` in `ci/release.Jenkinsfile` to keep publishing scans (the `--scan` flag can stay or be dropped). Without it, builds run fine but won't publish.
Verification
`./gradlew help` (no opt-in) configures cleanly: plugin resolves, no terms accepted, no scan published. The opt-in publish path was intentionally not exercised here to avoid uploading a scan.
🤖 Generated with Claude Code