C Y B E R D R E A D

Analyze the Future

Google Cloud Logo

Getting Started

The process for creating a CI/CD pipeline on GCP can be difficult to navigate for inexperience developers.  This post will hopefully clarify the steps to get your app running on GCP using a CI/CD process.  Step 1 is to create an Express app and run it locally.  Next add an app.yaml file and set the runtime to nodejs10.  Create a GitHub account and push your project to the GitHub repository.  If you already have a GitHub account, just create a new repository.

GCP Configuration

You’ll need to create a new GCP project.  Once that’s created select your project and navigate to Cloud Source Repositories.  On the Cloud Source Repository page on the top right select “Add a Repository”.

Add A Repository

Add a Repository
Add a Repository

When you add a repository, you’ll have to choose whether to create a new repo or add an external repo.  Select “Connect external repository”.

Connect External Repository

Connect External Repository
Connect External Repository

Select the “Connect Git Provider” dropdown and then Select GitHub.  Choose your repository.

Connect Git Provider

Connect Git Provider

Let’s deploy the app without CI/CD configured first.  While in your Cloud Source Repository select “Cloud Console” and then deploy your app to App Engine.

gcloud app deploy app.yaml 
Open the app to view your application running on Google App Engine.

App Before CI/CD

App Before CICD
App Before CICD

Enable the App Engine Admin SDK and register your project.

Enable Register Admin API

Enable Register Admin API
Enable Register Admin API

Register your application for the Cloud Build API.  Grant App Engine access to the Cloud  Build service account.  The Service Account Configuration is in IAM.

Service Account Registration

Service Account Registration
Service Account Registration

Select the pencil icon on the right of the row of the Cloud Build service account.  Choose “Add another role”.  Select “App Engine” and then “App Engine Admin” then save.  Let’s create our cloudbuild.yaml file.

Cloudbuild Yaml

Cloud Build Yaml
Cloud Build Yaml

Open the Cloud Build page and click “Create trigger”.

Cloud Build Create Trigger

Cloud Build Trigger
Cloud Build Trigger

Set Cloud Source Repository as the source then select your repository.  Set the Trigger settings:

  1. Set the Trigger type to “Branch”
  2. Under Build Configuration select “cloudbuild.yaml”
  3. Click “Create trigger”

Cloud Build Config

Cloud Build Config
Cloud Build Config

Time to Test

Make a change to your application to test the build and deployment process.  Open the “Cloud Build History” page and verify the build was successful.

Cloud Build History Details

Cloud Build History Details
Cloud Build History Details

Confirm the deployment to Google App Engine was made successfully.

CI/CD To App Engine

CICD to Appengine
CICD to Appengine

Summary

In order not to incur additional charges, you’ll need to delete your GCP project.  Many steps were involved in setting up a CI/CD pipeline from GitHub to App Engine.  Comparing this process to setting up a CI/CD pipeline in Azure, you’ll see that GCP still have a ways to go.  The process in Azure is much more simple and streamlined.  Nevertheless, GCP is becoming more user friendly and more importantly, developer friendly.  Hopefully the steps above is enough to get you to try GCP.  You can find a link to the repository here.

Related Post

Leave a Comment

Cyberdread Newsletter