Skip to content

fix: repair build scan config via Develocity plugin (opt-in)#460

Merged
SJrX merged 3 commits into
242.xfrom
fix-develocity-build-scan
Jun 20, 2026
Merged

fix: repair build scan config via Develocity plugin (opt-in)#460
SJrX merged 3 commits into
242.xfrom
fix-develocity-build-scan

Conversation

@SJrX

@SJrX SJrX commented Jun 20, 2026

Copy link
Copy Markdown
Owner

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:

  1. is a settings plugin — there is no project-level `buildScan` extension, so `findByName(...)` returns null and the `?.` silently no-ops; and
  2. renamed the properties to `termsOfUseUrl` / `termsOfUseAgree`.

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

  • Apply `com.gradle.develocity` 4.4.3 explicitly in `settings.gradle.kts` (verified compatible with Gradle 5.0+, incl. 9.5.x). Deterministic across wrapper bumps.
  • Configure with the current API and keep it opt-in: terms accepted and scan published only when `-PbuildScan` is passed. Local/contributor builds neither accept Gradle's ToU nor upload environment data.
  • Remove the dead legacy block from `build.gradle.kts`.

```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

Steve Ramage and others added 2 commits June 20, 2026 07:24
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>
@SJrX SJrX force-pushed the fix-develocity-build-scan branch from f72ea4e to d9930e3 Compare June 20, 2026 14:24
@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

Test Results

1 084 tests   1 084 ✅  47s ⏱️
  281 suites      0 💤
  281 files        0 ❌

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>
@SJrX SJrX merged commit f81b38b into 242.x Jun 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant