Deploying to App Engine Stay organized with collections Save and categorize content based on your preferences.
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:
Have your application source code ready. Your source code needs to be storedin a repository such as GitHub or Bitbucket.
To run the
gcloudcommands 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
In the Google Cloud console, go to thesettings Cloud BuildPermissions page:
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.- In the Assign Service Account User Role panel,choose a service account to impersonate and then clickGrant Permission.
- 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.
- App Engine Admin (
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:
Create aCloud Build configuration filenamed
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.cloudbuild.yamlorcloudbuild.json.In the config file:
- Add a
namefield to specify thecloud-sdkbuild step. - Add an
entrypointfield to use thebashtool whencloud-sdkis invoked. In the
argsfield, invoke thegcloud app deploycommand and set atimeoutforApp Engine to use when it invokes Cloud Build. This is required because Cloud Buildbuild steps and builds have a default timeout of 10 minutes and App Enginedeployments could take longer than that to complete. Specifying a longer timeoutwill make sure that the build doesn't timeout ifgcloud app deploytakeslonger than 10 minutes to complete.Timeout errors when using the App Engine standard environment:You can configure timeouts as described here only when using the App Engineflexible environment. The App Engine standard environment does not allowthe build timeout to be configured. If you're using Cloud Buildfor deploying on the App Engine standard environment, and your buildis failing with a timeout error, consider using the App Engine flexibleenvironment orCloud Runinstead of the App Engine standard environment.
Add abuild
timeoutvalue ofmore than 10 minutes.
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"}- Add a
Start the build, where
SOURCE_DIRECTORYis the path or URL to the sourcecode andREGIONis 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:
In your repository, add a config file with stepsto invoke the
gcloud app deploycommand: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"}Create a build trigger with the config file created in the previous step:
Open theTriggers page in the Google Cloud console:
Select your project from the project selector drop-down menu at the top ofthe page.
ClickOpen.
ClickCreate trigger.
On theCreate trigger page, enter the following settings:
Enter a name for your trigger.
Select the repository event to start your trigger.
Select the repository that contains your source code and buildconfig file.
Specify the regular expression for the branch or tag name that will start yourtrigger.
Configuration: Choose the build config file you createdpreviously.
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
- Learn how todeploy on Cloud Run
- Learn how toperform blue-green deployments on Compute Engine
- Learn how todeploy on GKE
- Learn how todeploy on Cloud Run functions
- Learn how todeploy on Firebase
- Learn how totroubleshoot build errors.
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.