Sample project of Katalon tests integrated with Gitlab-CI and Docker
Before you begin, ensure:
- You have a Gitlab account and you already put your project in a Git repository.
- You have Katalon Studio installed and you have created a test suite with one or more test cases.
- Docker is installed.
GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.
You can choose to install the GitLab Runner application on infrastructure that you own or manage. If you do, you should install GitLab Runner on a machine that’s separate from the one that hosts the GitLab instance.
GitLab Runner can also run inside a Docker container or be deployed into a Kubernetees cluster.
We'll see how to run it on a Docker container.
The general rule is that every GitLab Runner command that normally would be executed as:
gitlab-runner <Runner command and options...>
can be executed with:
docker run <chosen docker options...> gitlab/gitlab-runner <Runner command and options...>
To run gitlab-runner inside a Docker container, you need to make sure that the configuration is not lost when the container is restarted. To do this, there are two options, which are described below.
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
- Create the Docker volume:
docker volume create gitlab-runner-config
- Start the Runner container using the volume we just created:
docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v gitlab-runner-config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
To register a runner using a Docker container:
- For local system volume mounts:
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
- For Docker volume mounts:
docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest register
Then:
- Enter your GitLab instance
URL
. - Enter the
token
you obtained to register the runner. - Enter a description for the runner.
- Enter the
tags
associated with the runner, separated by commas (e.g. docker, shell, ssh). - Provide the
runner executor
. - If you entered docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml.
In our case the default image is
katalonstudio/katalon
For more info: https://docs.gitlab.com/runner/install/docker.html
image: katalonstudio/katalon
services:
- docker:dind
stages:
- test
run_katalon_test_suite:
stage: test
tags:
- docker
script:
- katalon -noSplash -runMode=console -consoleLog -projectPath=
"<Your_Project_Directory>" -retry=0
-testSuitePath="Test Suites/<Test_Suite_Name>" -executionProfile=
"default" -browserType="Chrome (headless)"
After saving some changes, push them to your git repository. After that, open the repository > CI/CD > Pipelines
You can see one of the following marks in your pipeline: