Adding steps after pushing images in GCP Cloud Container Builder

3/15/2017

I’m using "Google Cloud Container Builder" to build and deploy my containers, but I need to do my build steps, then push my images, the do my deploy steps.

As far as I know, the way to push images is by adding

images:
- 'gcr.io/$PROJECT_ID/image1'
- 'gcr.io/$PROJECT_ID/image2'

to the bottom of the cloudbuild.yaml file, but what if I need to do steps after I’ve pushed the images?

-- Simon I
gcp
google-container-registry
google-kubernetes-engine

1 Answer

3/15/2017

At this time, there is no way to take additional steps as part of that build process once the images have been pushed. If you want to take additional steps after a successful push, you have a few options:

  1. Use a build step to push your images instead; Container Builder will treat that like any other step. The supported docker build step could be used in this way to do a docker push... using the same credentials that your build uses. Note that if you go this route, you would (presumably) omit the images field from your cloudbuild.yaml (unless there are other images you want pushed).
  2. The other possibility is to have two separate builds. You could listen for GCR push notifications on Cloud Pub Sub; when the first build pushes the expected images, use that as a trigger to launch the second build.

Does one of these solutions give you what you need?

(Disclosure: I'm a Google Engineer who works on Container Builder.)

-- David Bendory
Source: StackOverflow