Google App Engine Deployment
For a minimal configuration, add the following to your
deploy: provider: gae keyfile: "YOUR SERVICE ACCOUNT JSON FILE" project: "YOUR PROJECT ID"
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.
It is strongly recommended that you encrypt your key before committing it to a repo. First make sure you have the Travis command line tool installed. Then execute the following command from the terminal:
travis encrypt-file client-secret.json --add
--add flag automatically adds the decryption step to the .travis file.
Keep in mind that the above command has to run in your project directory, so it can modify the
.travis.yml for you.
More detailed instructions for encrypting keys using Travis can be found here.
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 keyfile: ... 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://your-project-id.appspot.com. If the version flag is set instead, it will deploy to
Branch to deploy from #
By default, Travis will only deploy from your master branch.
You can also explicitly specify the branch to deploy from with the on option:
deploy: provider: gae keyfile: ... project: ... on: production
Alternatively, you can also configure it to deploy from all branches:
deploy: provider: gae keyfile: ... project: ... on: all_branches: true
Builds triggered from Pull Requests will never trigger a deploy.
Deploying without Promoting #
By default, when your application is deployed it will be promoted to receive all traffic. You can disable that using the
deploy: provider: gae keyfile: ... project: continuous-deployment-demo 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
deploy: provider: gae keyfile: ... project: continuous-deployment-demo no_stop_previous_version: true
Skipping Cleanup #
Many App Engine apps use pip to vendor library requirements into the directory, and sometimes you need build artifacts or other credentials to deploy. If so, you want to avoid the Travis cleanup step that will clean you working directory before the deploy.
deploy: provider: gae skip_cleanup: true
Example Repo #
See this link 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.
Other Available Configuration Options #
- project: Project ID used to identify the project on Google Cloud.
- keyfile: Path to the JSON file containing your Service Account credentials in JSON Web Token format. To be obtained via the Google Developers Console. Defaults to
"service-account.json". Note that this file should be handled with care as it contains authorization keys.
- config: Path to your module configuration file. Defaults to
"app.yaml". This file is runtime dependent (Go, Java, PHP, Python)
- 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. See
gcloud app deploy
- default: Flag to set the deployed version to be the default serving version. See
gcloud app deploy
- verbosity: Let’s you adjust the verbosity when invoking
"gcloud". Defaults to
- docker_build: If deploying a Managed VM, specifies where to build your image. Typical values are
"remote"to build on Google Cloud Engine and
"local"which requires Docker to be set up properly (to utilize this on Travis CI, read Using Docker on Travis CI). Defaults to