Building repositories from GitHub Enterprise

Stay organized with collections Save and categorize content based on your preferences.

Cloud Build enables you to create triggers on a GitHub Enterprise instance. This page explains how you can use GitHub Enterprise triggers to invoke builds in response to commits or pull requests from a GitHub Enterprise instance.

Before you begin

  • Enable the Cloud Build and Secret Manager APIs.

    Enable the APIs

Creating a GitHub Enterprise trigger

This section explains how you can create a trigger and link it your GitHub Enterprise installation. If you want to use GitHub Enterprise triggers in a private network, see Building repositories from GitHub Enterprise in a private network for further instructions.


To learn how to create triggers using the GitHub triggers, see Creating GitHub triggers.


The following JSON template shows you how you can create triggers via the command line:

      "filename": "cloudbuild.yaml",
      "name": "trigger-name",
      "description": "trigger-description",
      "github": {
          "push": {
              "branch": ".*",
          "owner": "owner",
          "name": "repo-name",
      "enterprise_config_resource_name": "projects/project-number/githubEnterpriseConfigs/id"
      "include_build_logs": "INCLUDE_BUILD_LOGS_WITH_STATUS"


  • trigger-name is the name for the trigger
  • trigger-description is a description for the trigger
  • owner is the owner of the GitHub repository.
  • repo-name is the name of the GitHub repository.
  • project-number is the number of the Cloud project.
  • id is the ID of your GitHubEnterpriseConfig.
  • [OPTIONAL] _include_build_logs is a field you can specify to show build logs for your repositories. This flag is supported for builds from GitHub and GitHub Enterprise repositories.

Enter the following curl command in your terminal, where project-id is the Cloud project ID:

  curl -X POST -H "Authorization: Bearer "$(gcloud auth print-access-token) -H "Content-Type: application/json; charset=utf-8" -d @trigger.json

Your trigger has now been created.

Data sharing

The data sent to GitHub Enterprise from Cloud Build helps you identify triggers by name and see build results on GitHub Enterprise.

The following data is currently shared between Cloud Build and GitHub Enterprise:

  • Cloud project ID
  • Trigger name
  • Build logs

If you created triggers prior to August 2020, data sharing may not be enabled for your project. You can enable data sharing for all GitHub Enterprise triggers in your project by clicking Enable on the Cloud Build Data sharing tab.

If you have required status checks enabled for a GitHub Enterprise repository, enabling data sharing may temporarily break status checks. You can adjust status check configurations to look for your trigger name by:

  • Disabling any Cloud Build-specific required checks on the GitHub repository
  • Ensuring that data sharing is enabled in Cloud Build
  • Executing a new build in Cloud Build that posts statuses to your repository
  • Re-enabling required status checks, selecting trigger name

Next steps