|
| 1 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | +/* |
| 3 | + * Develocity — Build Scans and remote Build Cache on the OSS Community instance |
| 4 | + * (https://community.develocity.cloud), project `meshtastic`. |
| 5 | + * |
| 6 | + * Replaces the former self-hosted HttpBuildCache: GRADLE_CACHE_URL / _USERNAME / |
| 7 | + * _PASSWORD are no longer read anywhere in this repo. |
| 8 | + */ |
| 9 | + |
| 10 | +def isCI = System.getenv("CI") != null |
| 11 | + |
| 12 | +develocity { |
| 13 | + server = "https://community.develocity.cloud" |
| 14 | + projectId = "meshtastic" |
| 15 | + buildScan { |
| 16 | + uploadInBackground = !isCI |
| 17 | + // Unauthenticated builds (fork PRs, developers who never provisioned a key) |
| 18 | + // publish nothing rather than failing. |
| 19 | + publishing.onlyIf { it.authenticated } |
| 20 | + // Fingerprints power cache-miss comparison (CI debugging); skip the payload locally. |
| 21 | + capture { fileFingerprints = isCI } |
| 22 | + // Public instance: no machine identity. Constants on purpose — scans already |
| 23 | + // record OS/CPU and CCUD adds CI metadata. Keep the `if` OUTSIDE the closures: |
| 24 | + // capture-free closures are what the configuration cache can serialize. |
| 25 | + obfuscation { |
| 26 | + ipAddresses { addresses -> addresses.collect { "0.0.0.0" } } |
| 27 | + externalProcessName { "external-process" } |
| 28 | + if (isCI) { |
| 29 | + username { "ci" } |
| 30 | + hostname { "ci-runner" } |
| 31 | + } else { |
| 32 | + username { "local-dev" } |
| 33 | + hostname { "local-machine" } |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +// Resolved outside the buildCache block: inside it the closure delegate is |
| 40 | +// BuildCacheConfiguration, which has no `develocity` property. |
| 41 | +def develocityBuildCache = develocity.buildCache |
| 42 | +def accessKey = System.getenv("DEVELOCITY_ACCESS_KEY")?.trim() |
| 43 | + |
| 44 | +buildCache { |
| 45 | + // Off on CI: runners are ephemeral and every hit comes from the remote anyway. |
| 46 | + local { |
| 47 | + enabled = !isCI |
| 48 | + } |
| 49 | + remote(develocityBuildCache) { |
| 50 | + enabled = true |
| 51 | + // Only authenticated CI writes, so unmerged and fork code cannot poison the cache. |
| 52 | + push = isCI && accessKey != null && !accessKey.isEmpty() |
| 53 | + } |
| 54 | +} |
0 commit comments