Continuous Deployment to App Engine Using Bitbucket Pipelines

This topic shows you how to set up a continuous delivery pipeline using Bitbucket and Google App Engine.


  • Understanding a sample application.
  • Creating authentication credentials for Bitbucket.
  • Creating a Bitbucket repository.
  • Creating a continuous delivery pipeline to App Engine.
  • Testing the pipeline.


This tutorial uses billable components of Google Cloud Platform (GCP), including:

  • Google App Engine

App Engine has free quotas that might cover this tutorial in a live production environment. Use the Pricing Calculator to generate a cost estimate based on your projected usage for this tutorial.

Before you begin

  1. Select or create a Cloud Platform project.

    Go to the Manage resources page

  2. Enable billing for your project.

    Enable billing

  3. Enable the App Engine Admin API and Google Books API APIs.

    Enable the APIs

  4. Create a Bitbucket account if you don't have one already.

Understanding the application

This tutorial demonstrates a Python app that runs on App Engine with Flask, a Python web framework, and interacts with the Google Books API. The sample app has a simple Python Flask endpoint that looks up the author of a book by its title.

Creating authorization credentials for Bitbucket

Create an App Engine service account and API key. Bitbucket needs this information to deploy to App Engine.

Creating an App Engine service account

  1. Navigate to the Google Cloud Platform Console credentials page.

  2. Click Create credentials > Service account key.

  3. Select New service account from the Service account dropdown.

  4. Input "Bitbucket authorization" in the Service account name field.

  5. Click the Create button. A copy of the JSON file downloads to your computer.

Creating an API Key

  1. Click Create credentials > API key.

  2. Copy the value that displays in the Your API key field. Use this value below when setting up environment variables.

Importing the tutorial repository in Bitbucket

  1. Navigate to Bitbucket and log in.

  2. Click Repositories in the left navigation.

  3. Click the + button, then click Repository.

  4. Click Import repository.

  5. Select Git from the Source dropdown.

  6. Input into the URL field.

  7. Click the Import repository button.

Creating the pipeline to App Engine

To create the pipeline, follow the Atlassian instructions to enable Bitbucket Pipelines.

Next, you would typically configure the pipeline by editing the bitbucket-pipelines.yml file. Because the repository you imported contains an already-configured version of the bitbucket-pipelines.yml file, you don't need to complete any additional pipeline configuration steps for this tutorial.

To learn more about pipeline configuration, see the Bitbucket documentation.

Setting up environment variables

  1. In the left navigation of Bitbucket, click Settings.
  2. Then, under the PIPELINES heading, click Environment variables.
  3. Add the following three environment variables.

    • Input CLOUDSDK_CORE_PROJECT in the Type variable field. Input your Cloud Platform Console project ID in the Type value field. Click the Add button.

    • Input GOOGLE_API_KEY in the Type variable field. Input the value from Creating an API key in the Type value field. Click the Add button.

    • Input GOOGLE_CLIENT_SECRET in the Type variable field. Open the JSON file you downloaded in the Creating an App Engine service account section, and paste the file's contents into the Type value field. Click the Add button.

Testing the pipeline

Test that the pipeline triggers as expected when changing the source code.

  1. Click Source in the left navigation.

  2. Click the file name, then click the Edit button to edit the file.

  3. Change the text "This repo" to "This repository" on line 5.

  4. Click the Commit button, then click the Commit button in the dialog.

  5. Click Pipelines in the left navigation. You will see a pipeline entry associated with the latest commit.

  6. Click the pipeline entry to see details about the pipeline status.

  7. Wait until the pipeline status string changes to Successful. This indicates the application changes deployed successfully.

To manually verify that the application deployed, navigate to the following URL in a web browser. Replace [YOUR_PROJECT_ID] with your project ID.


The text "James Joyce" displays.

You can test the app further by replacing the word "ulysses" in the URL with a different book title.

Cleaning up

To avoid incurring charges to your Google Cloud Platform account for the resources used in this tutorial:

Deleting the project

The easiest way to eliminate billing is to delete the project you created for the tutorial.

To delete the project:

  1. In the Cloud Platform Console, go to the Projects page.

    Go to the Projects page

  2. In the project list, select the project you want to delete and click Delete project. After selecting the checkbox next to the project name, click
      Delete project
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

What's next

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...