I have this pipeline which is supposed to be updated once a push is done. Here’s the cloudbuild.yaml file that should build the new code and deploy to the pipeline:
# Build and tag Docker images
- name: 'gcr.io/k8s-skaffold/pack'
entrypoint: 'pack'
args:
[
"build", "--builder=gcr.io/buildpacks/builder", "--publish", "us-central1-docker.pkg.dev/my-project/docker-repo/my-project-staging:$SHORT_SHA", "--env=GOOGLE_ENTRYPOINT=flask run"
]
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
[
"deploy", "releases", "create", "release-${SHORT_SHA}",
"--delivery-pipeline", "staging-pipeline",
"--region", "us-central1",
"--annotations", "commitId=${REVISION_ID}",
"--images", "staging-image=us-central1-docker.pkg.dev/my-project/docker-repo/my-project-staging:$SHORT_SHA"
]
Since I’m building it from scratch, both build and deploy get some errors here and there. But sometimes when I push some new code to test a correction, Cloud Build gives me the following error:
Uploading tarball of [.] to [gs://5ab97cc8958b4855a3ca3ad7b7366eae_clouddeploy/source/1677270496.103914-264a45a8a7614e67851aebb2f5d297f4.tgz]
ERROR: (gcloud.deploy.releases.create) ALREADY_EXISTS: Resource ‘projects/my-project/locations/us-central1/deliveryPipelines/staging-pipeline/releases/release-22df310’ already exists
- ‘@type’: type.googleapis.com/google.rpc.ResourceInfo
resourceName: projects/my-project/locations/us-central1/deliveryPipelines/staging-pipeline/releases/releases-22df310
It seems like even though new code was pushed, the release’s short SHA is the same as the previous one. Is there a way to replace the previous, defective release with the current so I don’t get this error?