I noticed on Jenkins when calling two gradle commands one after another that credentials were not updated in case like:
// Here credentials are fetched with read-only access for build
sh "./gradlew build"
// Here we set service account with write permissions, but credentials are not updated, so publish fails
withCredentials([file(credentialsId: env.GCP_SERVICE_ACCOUNT_FILE, variable: 'GOOGLE_APPLICATION_CREDENTIALS')]) {
sh "./gradlew publish"
}
I noticed the same thing locally:
I ran ./gradlew build with account that did not have any gcp artifact permissions, build failed
Naturally I did gcloud auth login with account with permissions
I ran ./gradlew build build failed again...
After 15 minutes of debugging I tried ./gradlew --stop and after that ./gradlew build worked
This behaviour is most likely due to Gradle daemon. I am not sure if this is a feature or a bug, but it's annoying to debug and maybe needs a fix.
Tested with: "com.google.cloud.artifactregistry.gradle-plugin" version "2.1.1"
I noticed on Jenkins when calling two gradle commands one after another that credentials were not updated in case like:
I noticed the same thing locally:
./gradlew build
with account that did not have any gcp artifact permissions, build failedgcloud auth login
with account with permissions./gradlew build
build failed again..../gradlew --stop
and after that./gradlew build
workedThis behaviour is most likely due to Gradle daemon. I am not sure if this is a feature or a bug, but it's annoying to debug and maybe needs a fix.
Tested with:
"com.google.cloud.artifactregistry.gradle-plugin" version "2.1.1"