Deploying to App Engine

This page explains how to deploy applications to App Engine usingCloud Build. If you're new to Cloud Build, read thequickstarts and thebuild configuration overview first.

App Engine is a fully managed, serverless platform for developing and hostingweb applications at scale. For more information on App Engine, read theApp Engine documentation.

Before you begin

  • Enable the App Engine API:

    Enable the App Engine API

  • Have your application source code ready. Your source code needs to be storedin a repository such as GitHub or Bitbucket.

  • To run thegcloud commands in this page, installtheGoogle Cloud CLI.

Caution: Effective June 17, 2024, Cloud Source Repositories isn't available to new customers. If your organization hasn't previously used Cloud Source Repositories, you can't enable the API or use Cloud Source Repositories. New projects not connected to an organization can't enable the Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to June 17, 2024 are not affected by this change.

Required Identity and Access Management permissions

  1. In the Google Cloud console, go to the Cloud BuildPermissions page:

    Go toPermissions

  2. For yourspecified Cloud Build service accountordefault Cloud Build service account, set the status of the following roles toEnabled:

    • App Engine Admin (roles/appengine.appAdmin) | Lets Cloud Build deploy new versions to App Engine.
    • Storage Admin (roles/storage.admin) | Enables reading and writing from Cloud Storage.
    • Artifact Registry Writer (roles/artifactregistry.writer) | Allows pulling images from and writing to Artifact Registry.
    • Logs Writer (roles/logging.logWriter) | Allows log entries to be written to Cloud Logging.
    • Cloud Build Editor (roles/cloudbuild.builds.editor) | Allows your service account to run builds.

Configuring the deployment

Cloud Build lets you use any publicly available container imageto execute your tasks. You can do this by specifying the image in a buildstepin the Cloud Build config file.

App Engine provides thegcloud app deploy command, which builds an image withyour source code and deploys that image on App Engine. You can use thecloud-sdkimage as a build step in your config file to invokegcloud commands within the image.Arguments passed to this build step are passed to the gcloud CLI directly,allowing you to run anygcloud command in this image.

To deploy an application to App Engine, use the following steps:

  1. Create aCloud Build configuration filenamedcloudbuild.yaml orcloudbuild.json.

    Note: Do not store the config file in the same directory as the source codebecause the gcloud CLI may interpret that you want to deploy the appusing Docker using Cloud Build. Instead, store your source in aseparate directory and create the config file in the parent directory.
  2. In the config file:

    YAML

    steps:-name:'gcr.io/google.com/cloudsdktool/cloud-sdk'entrypoint:'bash'args:['-c','gcloudconfigsetapp/cloud_build_timeout1600 &&gcloudappdeploy']timeout:'1600s'

    JSON

    {"steps":[{"name":"gcr.io/google.com/cloudsdktool/cloud-sdk","entrypoint":"bash","args":["-c","gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy"]}],"timeout":"1600s"}
  3. Start the build, whereSOURCE_DIRECTORY is the path or URL to the sourcecode andREGION is one of thesupported build regionsto start the build:

    gcloudbuildssubmit--region=REGIONSOURCE_DIRECTORY

Continuous deployment

You can automate the deployment of your software to App Engine by creatingCloud Build triggers. You can configure your triggers to build anddeploy images whenever you update your source code.

To automate your deployment to App Engine:

  1. In your repository, add a config file with stepsto invoke thegcloud app deploy command:

    YAML

    steps:-name:'gcr.io/google.com/cloudsdktool/cloud-sdk'entrypoint:'bash'args:['-c','gcloudconfigsetapp/cloud_build_timeout1600 &&gcloudappdeploy']timeout:'1600s'

    JSON

    {"steps":[{"name":"gcr.io/google.com/cloudsdktool/cloud-sdk","entrypoint":"bash","args":["-c","gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy"]}],"timeout":"1600s"}
  2. Create a build trigger with the config file created in the previous step:

    1. Open theTriggers page in the Google Cloud console:

      Open Triggers page

    2. Select your project from the project selector drop-down menu at the top ofthe page.

    3. ClickOpen.

    4. ClickCreate trigger.

      On theCreate trigger page, enter the following settings:

      1. Enter a name for your trigger.

      2. Select the repository event to start your trigger.

      3. Select the repository that contains your source code and buildconfig file.

      4. Specify the regular expression for the branch or tag name that will start yourtrigger.

      5. Configuration: Choose the build config file you createdpreviously.

    5. ClickCreate to save your build trigger.

Anytime you push new code to your repository, you will automatically start abuild and deploy on App Engine.

For more information on creating Cloud Build triggers, seeCreating and managing build triggers.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.