Created
March 13, 2023 16:54
-
-
Save cdsap/aa5c2c3c17545c2ac178305b04eaa1d8 to your computer and use it in GitHub Desktop.
GE configuration with incorrect server avoiding the Build Scan publication
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
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