- 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
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
Navigate to the Google Cloud Platform Console credentials page.
Click Create credentials > Service account key.
Select New service account from the Service account dropdown.
Input "Bitbucket authorization" in the Service account name field.
Click the Create button. A copy of the JSON file downloads to your computer.
Creating an API Key
Click Create credentials > API key.
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
Navigate to Bitbucket and log in.
Click Repositories in the left navigation.
Click the + button, then click Repository.
Click Import repository.
Select Git from the Source dropdown.
https://github.com/GoogleCloudPlatform/continuous-deployment-bitbucketinto the URL field.
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
- In the left navigation of Bitbucket, click Settings.
- Then, under the PIPELINES heading, click Environment variables.
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.
Click Source in the left navigation.
README.mdfile name, then click the Edit button to edit the file.
Change the text "This repo" to "This repository" on line 5.
Click the Commit button, then click the Commit button in the dialog.
Click Pipelines in the left navigation. You will see a pipeline entry associated with the latest commit.
Click the pipeline entry to see details about the pipeline status.
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.
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:
- In the Cloud Platform Console, go to the Projects page.
- In the project list, select the project you want to delete and click Delete project.
- In the dialog, type the project ID, and then click Shut down to delete the project.