Skip to content

GitLab CI/CD

The Klarent GitLab CI/CD component runs Klarent tests using the GitLab CI/CD component catalog.

Component catalog: gitlab.com/explore/catalog/foreai-co/cj-action

Add your Klarent service account key as a GitLab CI/CD variable:

  1. Go to your GitLab project → SettingsCI/CDVariables
  2. Click Add variable
  3. Key: CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY
  4. Value: paste your service account key from the Klarent Settings page
  5. Enable Mask variable to keep the value out of job logs
include:
- component: gitlab.com/foreai-co/cj-action/critical-journey@<version>
run-critical-journey:
variables:
TEST_ID: 'my-test-id'
SERVICE_ACCOUNT_KEY: $CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY
include:
- component: gitlab.com/foreai-co/cj-action/critical-journey@<version>
run-critical-journey:
variables:
TEST_SUITE_ID: 'my-test-suite-id'
SERVICE_ACCOUNT_KEY: $CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY
WAIT_TIMEOUT_SECONDS: '360'
WEBSITE_URL_OVERRIDE: 'https://beta-dev.my-awesome.com/2'
PARAMS_OVERRIDE: '{ "param1": "value1", "param2": "value2" }'

When CREATE_ISSUE_ON_FAILURE is enabled, the component automatically creates a GitLab issue when the test run fails. You must provide a GITLAB_TOKEN with sufficient permissions to create issues in your project.

include:
- component: gitlab.com/foreai-co/cj-action/critical-journey@<version>
run-critical-journey:
variables:
TEST_SUITE_ID: 'my-test-suite-id'
SERVICE_ACCOUNT_KEY: $CRITICAL_JOURNEY_SERVICE_ACCOUNT_KEY
CREATE_ISSUE_ON_FAILURE: 'true'
GITLAB_TOKEN: $GITLAB_TOKEN

Pass these as CI/CD variables in your job’s variables block.

Variable Required Default Description
TEST_ID No* ID of the test to run. Provide either this or TEST_SUITE_ID.
TEST_SUITE_ID No* ID of the test suite to run.
SERVICE_ACCOUNT_KEY Yes Your Klarent service account key.
WAIT_TIMEOUT_SECONDS No 300 Max seconds to wait for completion. Must be between 30 and 900.
WEBSITE_URL_OVERRIDE No Override the base website URL used during test execution.
PARAMS_OVERRIDE No Override default parameter values. Must be a valid JSON string with string keys and values.
BROWSER_TYPE_OVERRIDE No chromium Browser engine: chromium, firefox, or webkit.
CREATE_ISSUE_ON_FAILURE No false If true, creates a GitLab issue on test failure. Requires GITLAB_TOKEN.

* Either TEST_ID or TEST_SUITE_ID must be provided.