Folks, is there a way to configure the develocity ...
# develocity
j
Folks, is there a way to configure the develocity gradle plugin to use two gradle servers? the examples are typically in the form of
server = 'https://....'
w
Do you mean you want to publish Build Scan reports to two Develocity servers?
j
I mean, if it fails to publish to one server, try another.
c
What are you hoping to accomplish by publishing to two servers?
j
if one is down, try the other.
note that the semantics is not publishing to both server, but any available
c
This is not something we support today. This is something we intend to support in the future with our Edge node capability though, so such a feature is on our roadmap. Are you having any issues with your Develocity instance currently? Or are you just trying to be proactive in creating such a setup?
j
We are planning a migration in our on-prem instance (which also includes a different endpoint address).
I initially thought it would be easier to just update our gradle project to use the old develocity server and the new one to not cause disruption to our users
c
I see. While this case is not yet supported, I would recommend using support.gradle.com as an avenue for asking such questions. Our support team may be able to give you good strategies for dealing with migrations such as the one you are doing.
j
thanks for the input @Clay Johnson! we will try that 🙂
t
I've had to do similar. ended up doing a value source that pings the server inside my settings plugin.
Copy code
val urlProp = target.providers.gradleProperty("develocity.baseUrl")

val httpRequest = target.providers.of(HttpRequestCodeValueSource::class) {
  parameters.server.set(urlProp.orElse("<https://primary.develocity>"))
}
val checkResult = httpRequest.get()
val baseUrl = if (checkResult !in 200..399) {
  urlProp.orElse("<https://backup.develocity>")
} else {
  urlProp.orElse("<https://primary.develocity>")
}

develocity.server.set(baseUrl)
Copy code
abstract class HttpRequestCodeValueSource : ValueSource<Int, HttpRequestCodeValueSource.Parameters> {
  interface Parameters : ValueSourceParameters {
    val server: Property<String>
  }

  override fun obtain(): Int {
    return runCatching {
      val url = URI.create(parameters.server.get()).toURL()
      val conn = url.openConnection() as HttpURLConnection
      conn.responseCode
    }.getOrElse { -1 }
  }
}