Search code examples
google-cloud-buildgoogle-container-registry

Can google cloud build tag the built container as latest without cloudbuild.yaml?


I am successfully using Google Cloud Build to build my app into a container upon a push to the master branch, and store that built container in Google Cloud Registry.

I'm trying to simplify my setup, so have removed the cloudbuild.yaml in favor of Cloud Build's "auto detect docker" feature.

The container still gets built, but the difference is that the built image is not tagged as latest. latest is still assigned to an older build that had been done while the cloudbuild.yaml was still present.

How can I make it so that each new container build gets tagged as latest without using cloudbuild.yaml?


Solution

  • The answer is yes, here's how:

    • Edit the trigger used to build the container upon push to master
    • Under "Build type configuration", explicitly select "Dockerfile" rather than "Autodetected"
    • Under "Image name", edit the value to replace $COMMIT_SHA at the end with latest

    Run the trigger and you should see that your most recent container build is tagged with latest.