Run chaos experiments as GitLab pipelines
Guide to run a chaos experiment as a GitLab pipeline
This tutorial explains how you can create chaos experiments using Harness CE and run them as GitLab pipelines. Chaos experiments in Harness are created the same way in the chaos engineering module, irrespective of where they are invoked from.
Create a chaos experiment in the Harness Chaos Engineering module. Execute this experiment to verify the configuration and ensure that the resilience probes are working as expected. The experiment ID and resilience score determined from this experiment run will be used to integrate the experiment with GitLab.

chaos experiment with ID and resilience score
You will need the account scope details such as ACCOUNT_ID, PROJECT_ID, and CHAOS_EXPERIMENT_ID. You can get these values from your session URL. For example,
The strings marked in asterisk are the account ID, project ID, and chaos experiment IDs respectively.
From your account profile page, generate an API key and copy it to a safe location (you will need it further).
Create a launch script. HCE APIs are used to invoke or launch a chaos experiment from the pipeline.
To simplify creating an API call with the required secure parameters and data, a CLI tool is provided. Use this tool to create an appropriate API command to include in the pipeline script.
Below is a sample launch script.
Insert chaos experiments into
.gitlab-ci.yaml. You can include the above-mentioned launch script in the GitLab pipeline as a stage or a step. In thescriptsection, add the scripts for launching, monitoring and retrieving results. For example:Retrieve the resilience score using the Harness Chaos API and take appropriate action in the pipeline. An example of how to use the Harness Chaos API is shown below.
Last updated
Was this helpful?