Building projects with Google Cloud Build

Let's perform the following steps to build the project from the Cloud Source repository that we created in the previous recipe:

  1. Here, we are going to use the Cloud Build product to build our project. First, log in to your GCP account. From the main Products menu, click on Cloud Build. As shown in the following screenshot, it is located under TOOLS:

  1. In the Cloud Build menu, choose Triggers and click on the Create trigger button, as shown in the following screenshot:

  1. Our code is in a Cloud Source repository, so select Cloud Source Repository and click on the Continue button. As you can see, the other options are Bitbucket and GitHub:

  1. The repositories on your account will be detected automatically. Select the sample-app repository and click on the Continue button:

  1. Set the following settings and leave the others unchanged:
Name: devopscookbook-trigger-1
Trigger type: Tag
Tag (regex): v.*
Build configuration: Cloud Build configuration file (yaml or json)

  1. Click on the Create trigger button.
  2. Switch back to the command line where kubectl has been configured to access your Kubernetes cluster and create a bucket. Replace the devopscookbook-kubernetes-manifests bucket name with a unique bucket name before you create it:
$ gsutil mb -l us-central1 gs://devopscookbook-kubernetes-manifests
  1. Enable bucket versioning on the bucket you created in step 6. This following command will enable versioning on Cloud Storage and let the bucket keep old versions of objects:
$ gsutil versioning set on gs://devopscookbook-kubernetes-manifests
  1. If you are not already in the source code folder, change directories to our source code:
$ cd sample-app
  1. Change the project ID in our Kubernetes deployment manifest files to your project:
$ sed -i s/PROJECT/devopscookbook/g k8s/deployments/*
  1. Commit the changes with a meaningful commit message similar to the following:
$ git commit -a -m "Change placeholder project ID to devopscookbook"
  1. Create a Git tag for the release and push the tag:
$ git tag v1.0.0 && git push --tags
  1. Switch back to the browser and click on History from the Cloud Code menu and confirm that the build has been triggered and successful:

With that, you've learned how to build a project using Google Cloud Build.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.93.0