Create CI/CD pipeline for Google App Engine with CircleCI 2.0


In previous post, I talked about how to create CI/CD pipeline for AWS Lambda Functions with CircleCI. Today, we are going to create a CI/CD pipeline for GAE(Google App Agine) with CircleCI 2.0.

The reasons I choice GAE are that it is free and zero effort of infrastructure management! Even, we do not need to containerize the application and GAE provides a maven plugin for Java applications, which make the deployment process very simple and smooth.

We need the following resources to create our CI/CD pipeline today:

  1. A GCP management account and a project.
  2. A Bitbucket or Github account.
  3. A CircleCI account linked with the above git account.
  4. A Google App Engine application.
  5. The source code of GAE application (my example is a Spring Boot Java application).

Set up Google App Engine

  • First, create a standard environment Google App Engine application in GCP web console as below.


  • Second, create a service key, which is used by CircleCI to deploy the application. Go to Credentials and click Create Credentials and then create a service account key in json format. We must keep this json file securely in a private place!


  • Third, go to API in GCP web console. Search “App Engine Admin API” and enable it for the project.


Deploy GAE through CircleCI

  • First, create “.circleci” folder at the root path of our application. Then, create a file in that folder.

set -e

# expecting the install directly in the home directory

echo ${GCLOUD_SERVICE_KEY} | base64 --decode --ignore-garbage > ${HOME}/gcloud-service-key.json

if ${GCLOUD} version 2>&1 >> /dev/null; then
    echo "Cloud SDK is already installed"

    cd ${INSTALL_DIR}
    wget ${SDK_URL} -O cloud-sdk.tar.gz
    tar -xzvf cloud-sdk.tar.gz

    ${GCLOUD} components install app-engine-java

${GCLOUD} auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
${GCLOUD} config set project ${GCLOUD_PROJECT}

  • Second, add environment variables for our project in CircleCI as below. The GCLOUD_PROJECT is the name of our GCP project and GCLOUD_SERVICE_KEY is the base64 value of the json service key file from the second step in previous section.


  • Third, set up config.yml file in “.circleci” folder and add a deploy job as below:

      - image: circleci/openjdk:8-jdk-node-browsers
      - checkout
      - restore_cache:
          key: v3-YOUR-PROJECT-{{ checksum ".circleci/" }}
      - run: mvn dependency:go-offline
      - run: /bin/bash .circleci/
      - run: mvn appengine:deploy
      - save_cache:
          key: v3-YOUR-PROJECT-{{ checksum ".circleci/" }}
            - ~/google-cloud-sdk
            - ~/.m2

Now, when we push any changes to our git repository, our code will be built by CircleCI and deploy to GAE automatically.


  1. Getting started with Google App Engine and Spring Boot

  2. Deploying Kotlin/Java applications to Google App Engine Standard with CircleCI