Automating Builds using Build Triggers

A build trigger instructs Container Builder to automatically build your image whenever there are changes pushed to the build source. You can set a build trigger to re-build your images on any changes to the source repository, or only changes that match certain criteria.

Build triggers can help ensure that your container images are always based on the latest version of their source code. They're also useful for building and testing feature branches prior to release or for automating the workflows that produce your container images.

This page explains how to create build triggers.

Before you begin

Creating a build trigger

To create a new build trigger:

  1. Open the Container Registry page in the Google Cloud Platform Console.

    Open the Container Registry page

  2. Select your project and click Open.

  3. In the left nav, click Build triggers.

  4. Click Create trigger.

  5. Select one of the following host repositories for your build source:

    • Cloud Source Repository
    • GitHub
    • Bitbucket
  6. Click Continue.

  7. From the list of available repositories, select the desired repository, then click Continue.

  8. Enter the following trigger settings:

    • Trigger Name: An optional name for your trigger.
    • Trigger Type: You can set a trigger to start a build on commits to a particular branch, or on commits that contain a particular tag. In either case, you can specify a regular expression with the branch or tag value to match.
    • Build Configuration: The Dockerfile or build config file (located in the remote repository) to use for each build that the trigger starts.

Using a Dockerfile

To use a Dockerfile for your build configuration, you'll need to specify the Dockerfile directory and supply a name for the resulting image.

When you've provided the Dockerfile and image name, you'll see a preview of the docker build command that your build will execute and a summary of the trigger configuration. Click Create trigger to save the build trigger.

Using a build config file

To use a build config file for your build configuration, you'll need to provide the location of a build config file.

Once you've set the location, you'll see a summary of the trigger. Click Create trigger to save the build trigger.

Testing a build trigger

To manually test a build trigger, click Run trigger on your trigger's entry in the triggers list.

Skipping a build trigger

In some cases, you may want to make a change to your source code but you don't want to trigger a build. For example, you might not want to trigger a build when you update documentation or configuration files.

In such scenarios, you can include [skip ci] or [ci skip] in the commit message, and a build will not be triggered.

If you want to run a build on that commit later, use the Run trigger button.

What's next

Send feedback about...

Cloud Container Builder