Skip to content

Instantly share code, notes, and snippets.

@cdsap
Created March 13, 2023 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdsap/aa5c2c3c17545c2ac178305b04eaa1d8 to your computer and use it in GitHub Desktop.
Save cdsap/aa5c2c3c17545c2ac178305b04eaa1d8 to your computer and use it in GitHub Desktop.
GE configuration with incorrect server avoiding the Build Scan publication
import javax.inject.Inject
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
plugins {
id("com.gradle.common-custom-user-data-gradle-plugin") version "1.8.1"
id("com.gradle.enterprise") version "3.12.4"
}
gradleEnterprise {
server = "https://INCORRECT-URL.com"
allowUntrustedServer = true
buildScan {
def curlRequest = providers.of(CurlRequestValueSource) {
it.parameters {
it.url.set(server)
}
}
def serverActive = curlRequest.get() == "0"
if (!serverActive) {
buildFinished {
println("\n$server not reachable")
}
}
publishAlwaysIf(serverActive)
capture {
taskInputFiles = true
}
uploadInBackground = System.getenv("CI") == null
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "My Application"
include ':app'
include ':mylibrary'
abstract class CurlRequestValueSource implements ValueSource<String, Parameters> {
final ExecOperations execOperations
interface Parameters extends ValueSourceParameters {
Property<String> getUrl()
}
@Inject
CurlRequestValueSource(ExecOperations execOperations) {
this.execOperations = execOperations
}
@Override
String obtain() {
return execOperations.exec{
it.commandLine("curl", "-s", "--max-time", "2", parameters.url.get())
it.ignoreExitValue = true
}.exitValue.toString()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment