Google Cloud Build
Cloud Build is a service that executes your builds on the Google Cloud Platform (GCP). Cloud Build can import source code from Google Cloud Storage, Cloud Source Repositories, GitHub, or Bitbucket, to continuously build, test, and deploy projects. For more information on Cloud Build, see the Cloud Build documentation: Cloud Build.
This tutorial shows you how to integrate your Katalon project with Cloud Build.
- You can find the sample project in our GitHub repository: katalon-studio-samples/ci-samples.
- A valid Katalon API key. See: Generate API keys.
- A GCP project. See Google Workspace developer documentation: Create a Google Cloud project.
- Google Cloud Build API enabled for your Google Cloud project. See Google Cloud documentation: Enabling an API in your Google Cloud project.
- Secret Manager API enabled for your GCP project. See Google Cloud documentation: Using secrets from Secret Manager.
Configure the GCP project
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 GCP secret to store your Katalon API key.
Configure the cloudbuild.yml
file
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:
-
Use a
docker
cloud builder to pull thekatalonstudio/katalon
Docker image from Docker Hub.- In the args field, you can specify an image version with the syntax
katalonstudio/katalon:<version_tag>
, for examplekatalonstudio/katalon:8.1.2
.
- In the args field, you can specify an image version with the syntax
-
Use a
docker
cloud builder to run thekatalonstudio/katalon
image as a container and execute the tests stored in the GitHub repository.-
In the args field, you can input your desired
katalonc
commands. All ofkatalonc
supported arguments can be found in this document: Command Syntax. -
In the secretEnv field, you can input the environment variables for the build. Here we have the
KATALON_API_KEY
variable to specify the use of a secret namedKATALON_API_KEY
.
-
Create a GCP secret for Katalon API key
As specified in the build configuration file, the KATALON_API_KEY
secret represents your Katalon API key. We need to define the secret in our project.
For detailed instructions on creating a GCP secret, refer to this Google Cloud guide: Creating and accessing secrets.
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, refer to this guide: Creating and managing build triggers.
Create a trigger
In our example, a trigger is created to build the code automatically whenever a Push to branch event occurs.
Test the trigger
To test the trigger, you can start the build manually by clicking Run on the trigger.
View build results
To view the build results, go to the History tab and select the latest build.
The build details are shown as follows:
We can see that the code build includes two steps: pulling the Docker image and executing the tests in a container.
To view test reports in TestOps, you can enable Katalon TestOps integration in your project. See: TestOps Integration.