Skip to main content

Google Cloud integration

Cloud Build is a service on the Google Cloud Platform (GCP) that automates the build, test, and deployment processes for projects. For more details, refer to the Cloud Build documentation.

Integrating Katalon with Cloud Build helps streamline your CI/CD pipeline and ensures automatic execution of Katalon test scripts whenever changes occur in the source code.

This tutorial shows you how to configure the cloudbuild.yml file, create a Google Cloud secret, and set up a Cloud Build trigger.
Note:
Important:
After setting up the GCP project, you need to configure the following components:
  • A cloudbuild.yml file at the root directory of your repository that contains the build configuration for Cloud Build.
  • A Google Cloud secret to store your Katalon API key.

Configure the cloudbuild.yml file

The cloudbuild.yml file specifies the instructions for Cloud Build to automate the building, testing, and deploying of your Katalon project.

Here in the sample GitHub repository, we have the following cloudbuild.yml file:

steps:
- name: 'docker'
args: ['pull', 'katalonstudio/katalon']
- name: 'docker'
entrypoint: 'sh'
args: ['-c', 'docker run -t --rm -v /workspace:/tmp/project katalonstudio/katalon katalonc.sh -projectPath=/tmp/project -browserType="Chrome" -retry=0 -retryStrategy=immediately -testSuiteCollectionPath="Test Suites/Simple Test Suite Collection" --config -webui.autoUpdateDrivers=true -apiKey=$$KATALON_API_KEY']
secretEnv: ['KATALON_API_KEY']
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/KATALON_API_KEY/versions/1
env: 'KATALON_API_KEY'

In the build configuration file, there are two build steps:

  1. Use a docker cloud builder to pull the katalonstudio/katalon Docker image from Docker Hub.
    • In the args field, specify an image version using the syntax katalonstudio/katalon:<version_tag>. For example, katalonstudio/katalon:8.1.2.
  2. Use a docker cloud builder to run the katalonstudio/katalon image as a container and execute the tests stored in your GitHub repository.
    1. In the args field, set your katalonc commands. For a list of katalonc supported arguments, refer to Command syntax.
    2. In the secretEnv field, input the environment variables, such as KATALON_API_KEY, to use the secret named KATALON_API_KEY.

Create a Google Cloud secret for Katalon API key

As specified in the build configuration file, the KATALON_API_KEY secret represents your Katalon API key. You need to define the secret for your project.

For detailed instructions on creating a Google Cloud secret, refer to this Google Cloud guide: Create a secret.

Google Cloud Platform secret manager

Create and test your build trigger

A Cloud Build trigger automatically starts a build whenever you make changes to your source code. You need to connect Cloud Build to the sample GitHub repository and then create a trigger that automatically monitors changes and builds code.

For detailed instructions on connecting to repositories and building triggers, see Create and manage build triggers.

Create a trigger

In our example, a trigger is created to build the code automatically whenever a Push to branch event occurs.

Google Cloud Platform trigger created

Test the trigger

To test the trigger, you can start the build manually by selecting RUN on the trigger.

Google Cloud Platform run trigger

View build results

To view the build results, go to the History tab and select the latest build.

Google Cloud Platform history tab

The build details are shown as follows:

Google Cloud Platform build details

The code build includes two steps: pulling the Docker image and executing the tests in a container.

To view test reports in TestOps, enable Katalon TestOps integration in your project. See TestOps integration.

Was this page helpful?