I am working on setting up CI CD pipeline for Spring boot application on GKE. While doing the CI using Cloud Build on GCP, Build fail while pushing the updated manifest to candidate branch. "Failed at Step 5" I could see below logs in the cloud build
Finished Step #4 - "Generate manifest"
Starting Step #5 - "Push manifest"
Step #5 - "Push manifest": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #5 - "Push manifest": + cd eureka-cloudbuild-env
Step #5 - "Push manifest": + git add kubernetes.yaml
Step #5 - "Push manifest": + git log --format=%an <%ae> -n 1 HEAD
Step #5 - "Push manifest": On branch candidate
Step #5 - "Push manifest": Your branch is up to date with 'origin/candidate'.
Step #5 - "Push manifest":
Step #5 - "Push manifest": nothing to commit, working tree clean
Step #5 - "Push manifest": + git commit -m Deploying image gcr.io/amcartecom/eureka-cloudbuild:v2
Step #5 - "Push manifest": Built from commit 34dfdd69af726f80d3b91b29127e0c77cc2a83cf of repository eureka-cloudbuild-app
Step #5 - "Push manifest": Author: root <983160928936@cloudbuild.gserviceaccount.com>
Finished Step #5 - "Push manifest"
ERROR
ERROR: build step 5 "gcr.io/cloud-builders/gcloud" failed: exit status 1
To set up this pipeline, I followed all the guidelines mentioned at https://cloud.google.com/kubernetes-engine/docs/tutorials/gitops-cloud-build
This tutorial's code supposes that build triggers when there are actual changes to the source code, and it looks like you are trying to trigger it manually from console. When there are no changes step 5 of cloudbuild.yaml exits with error status due to empty git commit, which by default exits with error status when there is nothing to commit.
You can use --allow-empty
flag with it according to man page, but keep in mind that it will create an actual commit even if it is the same as previous one. If you don't want such commit but just want to suppress the error you can explicitly add || exit 0
at the end of step 5 to ignore errors.