App Engine es una plataforma sin servidor totalmente gestionada para desarrollar y alojar aplicaciones web a gran escala. Para obtener más información sobre App Engine, consulta la documentación de App Engine.
Para ejecutar los comandos gcloud de esta página, instala la CLI de Google Cloud.
Ten a mano el código fuente de la aplicación que quieras compilar y desplegar en App Engine. El código fuente debe almacenarse en un repositorio, como Cloud Source Repositories, GitHub o Bitbucket.
Permisos de gestión de identidades y accesos necesarios
En la Google Cloud consola, selecciona tu proyecto.
Concede el rol Cuenta de servicio de Cloud Build
a la cuenta de servicio predeterminada de App Engine. Si la cuenta de servicio no aparece en la lista, localízala en la página Cuentas de servicio.
Asigna el estado Habilitado a los roles Administrador de App Engine y Usuario de cuenta de servicio.
Configuración del despliegue
Cloud Build te permite usar cualquier imagen de contenedor disponible públicamente para ejecutar tus tareas. Para ello, especifica la imagen en un step de compilación
en el archivo de configuración de Cloud Build.
App Engine proporciona el comando gcloud app deploy, que crea una imagen con tu código fuente y la despliega en App Engine. Puedes usar la cloud-sdk
imagen
como paso de compilación en tu archivo de configuración para invocar comandos de gcloud en la imagen.
Los argumentos que se transfieren a este paso de compilación se transfieren directamente a la CLI de gcloud, lo que te permite ejecutar cualquier comando gcloud en esta imagen.
Para desplegar una aplicación en App Engine, sigue estos pasos:
Añade un campo name para especificar el paso de compilación cloud-sdk.
Añade un campo entrypoint para usar la herramienta bash cuando se invoque cloud-sdk.
En el campo args, invoca el comando gcloud app deploy y define un timeout
para que App Engine lo use cuando invoque Cloud Build. Esto es necesario porque los pasos y las compilaciones de Cloud Build tienen un tiempo de espera predeterminado de 10 minutos, y las implementaciones de App Engine pueden tardar más en completarse. Si especificas un tiempo de espera más largo, te asegurarás de que la compilación no se agote si gcloud app deploy tarda más de 10 minutos en completarse.
Errores de tiempo de espera al usar el entorno estándar de App Engine:
solo puedes configurar los tiempos de espera como se describe en este artículo cuando usas el entorno flexible de App Engine. El entorno estándar de App Engine no permite configurar el tiempo de espera de compilación. Si usas Cloud Build para desplegar en el entorno estándar de App Engine y tu compilación falla con un error de tiempo de espera agotado, te recomendamos que uses el entorno flexible de App Engine o Cloud Run en lugar del entorno estándar de App Engine.
{"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"}
Inicia la compilación, donde SOURCE_DIRECTORY es la ruta o la URL del código fuente y REGION es una de las regiones de compilación admitidas para iniciar la compilación:
gcloudbuildssubmit--region=REGIONSOURCE_DIRECTORY
Despliegue continuo
Puedes automatizar el despliegue de tu software en App Engine creando activadores de Cloud Build. Puedes configurar tus activadores para que compilen e implementen imágenes cada vez que actualices el código fuente.
Para automatizar el despliegue en App Engine, sigue estos pasos:
En tu repositorio, añade un archivo de configuración con los pasos para invocar el comando gcloud app deploy:
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[[["\u003cp\u003eThis guide outlines how to deploy applications to App Engine using Cloud Build, a fully managed, serverless platform.\u003c/p\u003e\n"],["\u003cp\u003eTo deploy an application, you'll need to create a Cloud Build configuration file, which specifies the \u003ccode\u003ecloud-sdk\u003c/code\u003e image and uses the \u003ccode\u003egcloud app deploy\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe configuration requires enabling the App Engine API, installing the Google Cloud CLI, having application source code in a repository, and setting the necessary IAM permissions for Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003eContinuous deployment to App Engine can be automated by creating Cloud Build triggers that are activated by code updates in your repository.\u003c/p\u003e\n"],["\u003cp\u003eWhen deploying to the App Engine flexible environment, ensure to set a build timeout in the config file, but note that this isn't configurable in the App Engine standard environment; consider using the flexible environment or Cloud Run if timeout errors occur.\u003c/p\u003e\n"]]],[],null,["# Deploying to App Engine\n\nThis page explains how to deploy applications to App Engine using\nCloud Build. If you're new to Cloud Build, read the\n[quickstarts](/build/docs/quickstarts) and the\n[build configuration overview](/build/docs/build-config) first.\n\nApp Engine is a fully managed, serverless platform for developing and hosting\nweb applications at scale. For more information on App Engine, read the\n[App Engine documentation](/appengine/docs).\n\nBefore you begin\n----------------\n\n- Enable the App Engine API:\n\n [Enable the App Engine API](https://console.cloud.google.com/apis/library/appengine.googleapis.com)\n- To run the `gcloud` commands on this page, install the\n [Google Cloud CLI](/sdk).\n\n- Have your application source code that you want to build and deploy to App Engine\n handy. Your source code needs to be stored in a repository, such as\n Cloud Source Repositories, GitHub, or Bitbucket.\n\n| **Caution:** Effective June 17, 2024, Cloud Source Repositories isn't available\n| to new customers. If your organization hasn't\n| previously used Cloud Source Repositories, you can't enable the API or use\n| Cloud Source Repositories. New projects not connected to an organization can't enable the\n| Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to\n| June 17, 2024 are not affected by this change.\n\n### Required IAM permissions\n\n1. In the Google Cloud console, select your project.\n\n2. [Grant](/iam/docs/grant-role-console) the **Cloud Build Service Account**\n role to the App Engine default service account. If service account does not\n appear in the list, locate service account in **Service Accounts** page.\n\n [Go to Service\n Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)\n3. Grant the **App Engine Admin** role and **Service Account User** to the build\n service account:\n\n 1. In the Google Cloud console, go to the\n *settings* Cloud Build **Permissions** page:\n\n [Go to **Permissions**](https://console.cloud.google.com/cloud-build/settings)\n\n \u003cbr /\u003e\n\n 2. Set the status of the **App Engine Admin** role and the **Service Account User**\n role to **Enabled**.\n\nConfiguring the deployment\n--------------------------\n\nCloud Build lets you use any publicly available container image\nto execute your tasks. You can do this by specifying the image in a build `step`\nin the Cloud Build config file.\n\nApp Engine provides the `gcloud app deploy` command, which builds an image with\nyour source code and deploys that image on App Engine. You can use the [`cloud-sdk`\nimage](https://github.com/GoogleCloudPlatform/cloud-sdk-docker)\nas a build step in your config file to invoke `gcloud` commands within the image.\nArguments passed to this build step are passed to the gcloud CLI directly,\nallowing you to run any `gcloud` command in this image.\n\nTo deploy an application to App Engine, use the following steps:\n\n1. Create a [Cloud Build configuration file](/build/docs/build-config)\n named `cloudbuild.yaml` or `cloudbuild.json`.\n\n | **Note:** Do not store the config file in the same directory as the source code because the gcloud CLI may interpret that you want to deploy the app using Docker via Cloud Build. Instead, store your source in a separate directory and create the config file in the parent directory.\n2. In the config file:\n\n - Add a `name` field to specify the `cloud-sdk` build step.\n - Add an `entrypoint` field to use the `bash` tool when `cloud-sdk` is invoked.\n - In the `args` field, invoke the `gcloud app deploy` command and set a `timeout`\n for [App Engine to use when it invokes Cloud Build](/appengine/docs/standard/nodejs/testing-and-deploying-your-app#deploying_your_application). This is required because Cloud Build\n build steps and builds have a default timeout of 10 minutes and App Engine\n deployments could take longer than that to complete. Specifying a longer timeout\n will make sure that the build doesn't timeout if `gcloud app deploy` takes\n longer than 10 minutes to complete.\n\n **Timeout errors when using the App Engine standard environment** :\n You can configure timeouts as described here only when using the App Engine\n flexible environment. The App Engine standard environment does not allow\n the build timeout to be configured. If you're using Cloud Build\n for deploying on the App Engine standard environment, and your build\n is failing with a timeout error, consider using the App Engine flexible\n environment or [Cloud Run](/build/docs/deploying-builds/deploy-cloud-run)\n instead of the App Engine standard environment.\n - Add a [build `timeout`](/build/docs/build-config#build_steps) value of\n more than 10 minutes.\n\n ### YAML\n\n steps:\n - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'\n entrypoint: 'bash'\n args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']\n timeout: '1600s'\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/google.com/cloudsdktool/cloud-sdk\",\n \"entrypoint\": \"bash\",\n \"args\": [\n \"-c\",\n \"gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy\"\n ]\n }\n ],\n \"timeout\": \"1600s\"\n }\n\n3. Start the build, where \u003cvar translate=\"no\"\u003eSOURCE_DIRECTORY\u003c/var\u003e is the path or URL to the source\n code and \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is one of the [supported build regions](/build/docs/locations)\n to start the build:\n\n gcloud builds submit --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION\u003c/span\u003e\u003c/var\u003e \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSOURCE_DIRECTORY\u003c/span\u003e\u003c/var\u003e\n\nContinuous deployment\n---------------------\n\nYou can automate the deployment of your software to App Engine by creating\nCloud Build triggers. You can configure your triggers to build and\ndeploy images whenever you update your source code.\n\nTo automate your deployment to App Engine:\n\n1. In your repository, add a config file with steps\n to invoke the `gcloud app deploy` command:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'\n entrypoint: 'bash'\n args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']\n timeout: '1600s'\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/google.com/cloudsdktool/cloud-sdk\",\n \"entrypoint\": \"bash\",\n \"args\": [\n \"-c\",\n \"gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy\"\n ]\n }\n ],\n \"timeout\": \"1600s\"\n }\n\n2. Create a build trigger with the config file created in the previous step:\n\n 1. Open the **Triggers** page in the Google Cloud console:\n\n [Open Triggers page](https://console.cloud.google.com/cloud-build/triggers)\n 2. Select your project from the project selector drop-down menu at the top of\n the page.\n\n 3. Click **Open**.\n\n 4. Click **Create trigger**.\n\n On the **Create trigger** page, enter the following settings:\n 1. Enter a name for your trigger.\n\n 2. Select the repository event to start your trigger.\n\n 3. Select the repository that contains your source code and build\n config file.\n\n 4. Specify the regex for the branch or tag name that will start your\n trigger.\n\n 5. **Configuration**: Choose the build config file you created\n previously.\n\n 5. Click **Create** to save your build trigger.\n\nAnytime you push new code to your repository, you will automatically start a\nbuild and deploy on App Engine.\n\nFor more information on creating Cloud Build triggers, see\n[Creating and managing build triggers](/build/docs/automating-builds/create-manage-triggers).\n\nWhat's next\n-----------\n\n- Learn how to [deploy on Cloud Run](/build/docs/deploying-builds/deploy-cloud-run)\n- Learn how to [perform blue/green deployments on Compute Engine](/build/docs/deploying-builds/deploy-compute-engine)\n- Learn how to [deploy on GKE](/build/docs/deploying-builds/deploy-gke)\n- Learn how to [deploy on Cloud Run functions](/build/docs/deploying-builds/deploy-functions)\n- Learn how to [deploy on Firebase](/build/docs/deploying-builds/deploy-firebase)\n- Learn how to [troubleshoot build errors](/build/docs/troubleshooting)."]]