How to accept the Gradle build scan terms of service automatically

Originally posted on 2020-11-06

If you're using Gradle build scans you'll notice that the default settings are not very automation friendly because it requires you to accept the terms of service on each build. There's a good reason for this, they don't want people to accidentally publish private data to their service without opting in, but there wasn't a clear way to accept the terms of service automatically that I could find.

extensions.findByName("buildScan")?.withGroovyBuilder {
    setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
    setProperty("termsOfServiceAgree", "yes")
}

Interestingly enough, this works verbatim in the Kotlin DSL too!