Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle Build Cache config to permit read-only access #4296

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ pluginManagement {

rootProject.name = "ktor"

val CACHE_USER = System.getenv("GRADLE_CACHE_USER")
val gradleBuildCacheUser = System.getenv("GRADLE_CACHE_USER")?.ifBlank { null }
val gradleBuildCachePassword = System.getenv("GRADLE_CACHE_PASSWORD")?.ifBlank { null }

if (CACHE_USER != null) {
val CACHE_PASSWORD = System.getenv("GRADLE_CACHE_PASSWORD")
buildCache {
remote(HttpBuildCache::class) {
isPush = true
setUrl("https://ktor-gradle-cache.teamcity.com/cache/")
credentials {
username = CACHE_USER
password = CACHE_PASSWORD
}
val isCi = !System.getenv("TEAMCITY_VERSION").isNullOrBlank() || !System.getenv("CI").isNullOrBlank()

buildCache {
local {
// Disable local cache when on CI, to make sure CI updates the remote cache.
isEnabled = !isCi
}
remote<HttpBuildCache> {
setUrl("https://ktor-gradle-cache.teamcity.com/cache/")
// Only push when credentials are present, otherwise, permit read-only access
isPush = gradleBuildCacheUser != null && gradleBuildCachePassword != null
credentials {
username = gradleBuildCacheUser
password = gradleBuildCachePassword
}
}
}
Expand Down