Shape the future of software delivery and make your voice heard by taking the 2021 State of DevOps survey.

Creating manual triggers

This page explains how to create manual triggers. Manual triggers can be used to invoke builds manually, with the ability to override defined substitution variable values at invocation time prior to running a build. You can also schedule manual triggers to automatically run at a specifc time.

To learn how to start builds manually using the gcloud command line tool or the Cloud Build API, see Starting builds manually.

Before you begin

  • Enable the Cloud Build API.

    Enable the API

  • Have your source code ready.

Manual triggers

Manual triggers enable you to set up builds that are only executed when you invoke your trigger on connected repositories. Let's say you're creating a pipeline for deploying your source code to a staging or production environment. You might want to automate your workflow, but are only looking to invoke builds manually. You can define manual triggers to do so.

Manual triggers enable you to manually invoke builds by:

  • Fetching source code from a hosted repository with a specified branch or tag.
  • Parametizing your build with substitutions that don't need to be passed in manually each time you invoke a build.
  • Overriding defined substitution variable values at invocation time prior to invoking a build.

To invoke builds from your local working direrctory instead of a hosted repository or want to submit builds without creating a trigger, you can run the following gcloud command in your working directory:

gcloud builds submit --config build-config source-code

Where:

  • build-config is the path to the build config file.
  • source-code is the path or URL source code.

To learn more about how to use the gcloud command to start builds manually in your local directory, see Starting builds manually.

Creating manual triggers

To create a manual trigger:

  1. Open the Triggers page:

    Open the Triggers page

  2. Select your project from the top of the page and click Open.

  3. Click Create trigger.

  4. Enter the following trigger settings:

    • Name: A name for your trigger.
    • Description (Optional): A description for your trigger.
    • When: Select Manually run to set up your trigger so that builds only run when the trigger is manually invoked.
    • Source: Select the repository to build when the manual trigger runs.
    • Revision: Select the branch or tag to build when the manual trigger runs.
      • Branch: Set a trigger to build on this branch. You must specify a literal value. Regular expressions are not currently supported.
      • Tag: Set a trigger to build on this tag. You must specify a literal value. Regular expressions are not currently supported.
    • Configuration: Select the build config file located in your remote repository or create an inline build config file to use for your build.

      • Type: Select the type of configuration to use for your build.
        • Cloud Build configuration file (yaml or json): Use a build config file for your configuration.
        • Dockerfile: Use a Dockerfile for your configuration.
      • Location: Specify the location for your configuration.

        • Repository: If your config file is in located in your remote repository, provide the location of your build config file or the Dockerfile directory and a name for the resulting image. If your configuration is a Dockerfile, you can optionally provide a timeout for your build. When you've provided the Dockerfile and image name, you'll see a preview of the docker build command that your build will execute.
        • Inline: If you selected Cloud Build configuration file (yaml or json) as your configuration option, you can specify your build config inline. Click Open Editor to write your build config file in the Google Cloud Console using YAML or JSON syntax. Click Done to save your build config.
  5. Click Create to create your manual trigger.

Running manual triggers

To run a manual trigger using Google Cloud Console:

  1. Open the Triggers page in the Google Cloud Console.

    Open the triggers page

  2. Locate your trigger in the list.

  3. Click Run trigger.

    After clicking Run trigger, you will see the Run trigger window pane on the right side. If you specified fields such as a branch name, tag name, or substitution variables, you will be able to override these fields at invocation time.

    If you specified new variable values for your substitution, click Run trigger to invoke your build.

To run manual triggers on schedule, see Scheduling builds.

Next steps