Google App Engine Deployment

This page documents deployments using the next major version dpl v2, which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Be sure to read the v2 deployment overview.

Travis CI can automatically deploy to Google App Engine or Managed VMs after a successful build.

For a minimal configuration, add the following to your .travis.yml:

deploy:
  provider: gae
  keyfile: <keyfile>
  edge: true # opt in to dpl v2

Then go to the Google Cloud Console Dashboard and:

  • Enable “Google App Engine Admin API”,
  • Go to “Credentials”, click “Add Credential” and “Service account key”, finally click “JSON” to download your Service Account JSON file.

Add this file as an encrypted file to your repository and .travis.yml file.

Status #

Support for deployments to Google App Engine is *stable**.

Known options #

Use the following options to further configure the deployment.

project Project ID used to identify the project on Google Cloud — required, type: string
keyfile Path to the JSON file containing your Service Account credentials in JSON Web Token format. To be obtained via the Google Developers Console. Should be handled with care as it contains authorization keys. — type: string, default: service-account.json
config Path to your service configuration file — type: string or array of strings, default: app.yaml
version The version of the app that will be created or replaced by this deployment. If you do not specify a version, one will be generated for you — type: string
verbosity Adjust the log verbosity — type: string, default: warning
promote Whether to promote the deployed version — type: boolean, default: true
stop_previous_version Prevent the deployment from stopping a previously promoted version — type: boolean, default: true
install_sdk Whether to install the Google Cloud SDK — type: boolean, default: true

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Project to deploy #

By default, the project will be deployed with the same name as the repository. Usually, you will want to explicilty configure the project option to match the project ID found in your Cloud console (note that this is sometimes, but not always, the same as the project name).

You can explicitly set the project id via the project option:

deploy:
  provider: gae
  # ⋮
  project: continuous-deployment-demo

Version to deploy #

Either the version flag or the default option must be set. If default is true, the default version will be deployed to, which will be http://project-id.appspot.com. If the version flag is set instead, it will deploy to http://version.project-id.appspot.com.

Deploying without Promoting #

By default, when your application is deployed it will be promoted to receive all traffic. You can disable that using the no_promote option:

deploy:
  provider: gae
  # ⋮
  no_promote: true

In addition to that, and according to the Google Cloud SDK changelog, “in a future Cloud SDK release, deployments that promote the new version to receive all traffic will stop the previous version by default”.

You can prevent that from happening by setting the option no_stop_previous_version:

deploy:
  provider: gae
  # ⋮
  no_stop_previous_version: true

Example Repo #

See this repository for an example App Engine app with a Travis deployment configured. See the other branches in the project for Managed VMs examples, and examples without using this provider.

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #