Gitlab CI/CD integration
Run your Gatling Enterprise simulations from GitLab CI/CD.
The Gatling Enterprise Docker runner
This runner, packaged as a Docker image and published on Docker Hub, enables you to start a Gatling Enterprise simulation directly from your GitLab CI/CD pipelines.
This plugin doesn’t create a new Gatling Enterprise simulation, you have to create it using the Gatling Enterprise Dashboard before.
On Gatling Enterprise Self-Hosted, you can do it using the options provided by our build tools plugins:
Don’t forget to check out GitLab’s official documentation to learn how to write CI/CD pipelines on GitLab.
Docker Hub coordinates
The Docker image is published on Docker Hub with the following coordinates: gatlingcorp/enterprise-runner:1
.
You can check out the latest releases available from the GitHub project. You generally only need to specify the major version you want to use, currently 1
.
Pre-requisites
You must first create an API token. It will be used to authenticate with Gatling Enterprise.
You can store the API Token in a Gitlab CI Variable (make sure to check “Mask variable”) with the name GATLING_ENTERPRISE_API_TOKEN
, which our tools will detect automatically. Or if you use a vault to store secrets, store the API Token in your vault and retrieve its value to an environment variable named GATLING_ENTERPRISE_API_TOKEN
in your Gitlab CI/CD configuration file.
- the API token needs the All role.
The runner will also need the URL for your Gatling Enterprise instance. In the following examples, we will use http://my-gatling-instance.my-domain.tld
, but you must replace it with the correct URL for your Gatling Enterprise Self-Hosted instance.
Please also note that it must be accessible from the GitLab runners you plan to use (either the GitLab.com runners or your own self-managed runners).
We also assume that you have already configured a simulation on Gatling Enterprise. You can copy the simulation ID from the simulations list view. In the following examples, we will show the simulation ID as 00000000-0000-0000-0000-000000000000
.
See the Test execution documentation.
Quickstart (minimal job configuration)
In this example, we configure a workflow which will only start a simulation as already configured and uploaded on Gatling Enterprise.
Create a file named .gitlab-ci.yml
in your repository:
stages:
- load-test
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
# We assume GATLING_ENTERPRISE_API_TOKEN is available,
# e.g. configured on the GitLab project
# Specify the URL for your Gatling Enterprise Self-Hosted instance:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
# Specify your simulation ID:
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
Push this to GitLab. The pipeline will run automatically on new commits; you can also run it manually from your GitLab project’s CI/CD menu.
Configuration reference
Several options can be configured with environment variables. The Docker runner also provides several outputs which you can export to access in the following stages of your pipeline.
Inputs
Example:
stages:
- load-test
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
GATLING_ENTERPRISE_API_TOKEN: 'my-api-token' # Typically not hard-coded in the script!
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
EXTRA_SYSTEM_PROPERTIES: >
{
"sys_prop_1":"value 1",
"sys_prop_2":42,
"sys_prop_3":true
}
EXTRA_ENVIRONMENT_VARIABLES: >
{
"ENV_VAR_1":"value 1",
"ENV_VAR_2":42,
"ENV_VAR_3":true
}
FAIL_ACTION_ON_RUN_FAILURE: 'true'
WAIT_FOR_RUN_END: 'true'
OUTPUT_DOT_ENV_FILE_PATH: 'path/to/file.env'
RUN_SUMMARY_ENABLED: 'true'
RUN_SUMMARY_INITIAL_REFRESH_INTERVAL: '5'
RUN_SUMMARY_INITIAL_REFRESH_COUNT: '12'
RUN_SUMMARY_REFRESH_INTERVAL: '60'
-
GATLING_ENTERPRISE_URL
required: The URL for your Gatling Enterprise Self-Hosted instance. -
GATLING_ENTERPRISE_API_TOKEN
required: The API token used to authenticate with Gatling Enterprise. -
SIMULATION_ID
required: The ID of the simulation as configured on Gatling Enterprise. -
EXTRA_SYSTEM_PROPERTIES
optional: Additional Java system properties, will be merged with the simulation’s configured system properties. Must be formatted as a JSON object containing the desired key/value pairs. Values can be strings, numbers or booleans. -
EXTRA_ENVIRONMENT_VARIABLES
optional: Additional environment variables, will be merged with the simulation’s configured environment variables. Must be formatted as a JSON object containing the desired key/value pairs. Values can be strings, numbers or booleans. -
FAIL_ACTION_ON_RUN_FAILURE
optional (defaults totrue
): Iftrue
, the Action will fail if the simulation run ends in an error (including failed assertions). Note: if set tofalse
and the simulation ends in an error, some of the outputs may be missing (e.g. there will be no assertion results if the simulation crashed before the end). -
WAIT_FOR_RUN_END
optional (defaults totrue
): Iftrue
, the runner will wait for the end of te simulation run on Gatling Enterprise before terminating. Note: if set tofalse
, some of the outputs may be missing (there will be no status nor assertion results). -
OUTPUT_DOT_ENV_FILE_PATH
optional (defaults togatlingEnterprise.env
): path to a dotenv file where output values will be written -
RUN_SUMMARY_ENABLED
optional (defaults totrue
): Assumingwait_for_run_end
is also true, will regularly log a summary of the ongoing run to the console until it finishes. See also the logs section. -
RUN_SUMMARY_INITIAL_REFRESH_INTERVAL
optional (defaults to5
): Initial interval before displaying a new summary of the ongoing run in the console, in seconds. Should be a multiple of 5 (otherwise it will be rounded up). Only used a limited number of times (set byrun_summary_initial_refresh_count
) before switching to the interval set by run_summary_refresh_interval. See also the logs section. -
RUN_SUMMARY_INITIAL_REFRESH_COUNT
optional (defaults to12
): Number of times to userun_summary_initial_refresh_interval
as the interval before displaying a new summary of the ongoing run in the console. After that,run_summary_refresh_interval
will be used. This allows to avoid spamming the log output once the test run is well underway. See also the logs section. -
RUN_SUMMARY_REFRESH_INTERVAL
optional (defaults to60
): Interval before displaying a new summary of the ongoing run in the console, in seconds. Should be a multiple of 5 (otherwise it will be rounded up). See also the logs section.
Outputs
Outputs are written to a dotenv file, which can then be exported to make the variables available. Check out the GitLab documentation for more details on exporting dotenv files. Example:
stages:
- load-test
- post-load-test
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
# For Gatling Enterprise Self-Hosted, you must specify the URL:
# GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
artifacts:
reports:
dotenv: 'gatlingEnterprise.env' # Using the default value
print-output:
stage: post-load-test
image: alpine:latest
script: |
# Show that we can access the outputs exported by the previous stage
echo "RUN_ID=$RUN_ID"
echo "REPORTS_URL=$REPORTS_URL"
echo "RUNS_URL=$RUNS_URL"
echo "RUN_STATUS_CODE=$RUN_STATUS_CODE"
echo "RUN_STATUS_NAME=$RUN_STATUS_NAME"
echo "RUN_ASSERTIONS=$RUN_ASSERTIONS"
-
RUN_ID
: The ID of the run started by this runner. -
REPORTS_URL
: The URL of the reports page for this run. -
RUNS_URL
: The URL of the runs history page for this simulation. -
RUN_STATUS_NAME
: The name of the run’s final status (e.g.Successful
,AssertionsSuccessful
,AssertionsFailed
, etc.). -
RUN_STATUS_CODE
: The code of the run’s final status. -
RUN_ASSERTIONS
: The results of the run’s assertions, as a JSON array.
Logs
Every few seconds, the Docker runner logs to the console output a summary of the run’s current status. When the run ends, it logs the status of the run and the results of any assertions. Here’s the beginning and end of a very short duration example:
By default, logs are printed every 5 seconds the first 12 times (i.e. during 60 seconds), then every 60 seconds. This can be adjusted using the input variables RUN_SUMMARY_INITIAL_REFRESH_INTERVAL
, RUN_SUMMARY_INITIAL_REFRESH_COUNT
, and RUN_SUMMARY_REFRESH_INTERVAL
. The ongoing logs can also be completely disabled using the input variable RUN_SUMMARY_ENABLED: 'false'
: in this case, only the final results will be printed.
Sample use cases
Building from sources
In this example, we assume you have configured your repository on Gatling Enterprise to build from sources, from your GitHub repository’s main
branch. Every time the code on the main
branch gets updated, we run the updated simulation on Gatling Enterprise.
Feel free to use different trigger events or to configure the other inputs and outputs for the runner as documented above, according to your own use case. But keep in mind that Gatling Enterprise will only download and run your simulation scripts from the branch set in the simulation configuration!
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- load-test
# Run the simulation on Gatling Enterprise
# If it is configured to "build from sources" from the branch "main",
# it will download and run the updated version of the code
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
Using a binary repository
This workflow is defined in the GitLab repository which contains your Gatling simulation script built with one of our build tools plugins. In this example, every time the code on the main
branch gets updated, we build, package, and publish the current version of the simulation script, before starting the simulation on Gatling Enterprise.
In this example, we assume that:
- You have configured your repository on Gatling Enterprise to download from a binary repository, using Artifactory or Sonatype Nexus.
- You have configured your simulation to use the version marker
latest.integration
for the artifact published on the binary repository. - Your build is properly configured to publish to the binary repository, using Maven, Gradle, or sbt.
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- build
- load-test
# Build, package, and upload your Gatling project
build-gatling-simulation:
stage: build
# Gradle 8 and JDK 17; see https://hub.docker.com/_/gradle for other tags available
# See also https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml
# for other useful options for Gradle builds.
image: gradle:8-jdk17
script:
# Configure credentials in the build.gradle file using environment
# variables, which can be set on the GitLab project.
# See https://docs.gitlab.com/ee/user/packages/gradle_repository/#authenticate-with-a-ci-job-token-in-gradle
# The GitLab doc example uses a token to publish to GitLab Package
# Registry, you may need to configure e.g. username and password instead;
# see https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:authentication_schemes
- gradle publish
# Run the simulation on Gatling Enterprise
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- build
- load-test
# Build, package, and upload your Gatling project
build-gatling-simulation:
stage: build
# JDK 17 from Azul; see https://hub.docker.com/r/azul/zulu-openjdk for other tags available,
# or use another image configured with a JDK
# See also https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml
# for other useful options for Gradle builds.
image: azul/zulu-openjdk:17-latest
script:
# Configure credentials in the build.gradle file using environment
# variables, which can be set on the GitLab project.
# See https://docs.gitlab.com/ee/user/packages/gradle_repository/#authenticate-with-a-ci-job-token-in-gradle
# The GitLab doc example uses a token to publish to GitLab Package
# Registry, you may need to configure e.g. username and password instead;
# see https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:authentication_schemes
- gradle publish
# Run the simulation on Gatling Enterprise
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- build
- load-test
# Build, package, and upload your Gatling project
build-gatling-simulation:
stage: build
# Maven 3 and JDK 17; see https://hub.docker.com/_/maven for other tags available
# See also https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml
# for other useful options for Maven builds.
image: maven:3-openjdk-17-slim
script:
# ci_settings.xml is a Maven settings file included in the repository;
# the credentials in ci_settings.xml use environment variables, which
# can be set on the GitLab project.
# See https://docs.gitlab.com/ee/user/packages/maven_repository/#create-maven-packages-with-gitlab-cicd
# The GitLab doc example uses a token to publish to GitLab Package
# Registry, you may need to configure e.g. username and password instead;
# see https://maven.apache.org/settings.html#servers
- mvn deploy -s ci_settings.xml
# Run the simulation on Gatling Enterprise
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- build
- load-test
# Build, package, and upload your Gatling project
build-gatling-simulation:
stage: build
# Maven 3 and JDK 17; see https://hub.docker.com/_/maven for other tags available
# See also https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml
# for other useful options for Maven builds.
image: maven:3-openjdk-17-slim
script:
# ci_settings.xml is a Maven settings file included in the repository;
# the credentials in ci_settings.xml use environment variables, which
# can be set on the GitLab project.
# See https://docs.gitlab.com/ee/user/packages/maven_repository/#create-maven-packages-with-gitlab-cicd
# The GitLab doc example uses a token to publish to GitLab Package
# Registry, you may need to configure e.g. username and password instead;
# see https://maven.apache.org/settings.html#servers
- mvn deploy -s ci_settings.xml
# Run the simulation on Gatling Enterprise
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
workflow:
rules:
# Execute the pipeline only on pushes to the main branch
- if: $CI_COMMIT_BRANCH == "main"
stages:
- build
- load-test
# Build, package, and upload your Gatling project
build-gatling-simulation:
stage: build
# sbt 1.8.2 and JDK 17.0.5; sbtscala/scala-sbt does not provide 'latest' tags
# See https://hub.docker.com/r/sbtscala/scala-sbt for other tags available and for the latest versions
image: sbtscala/scala-sbt:eclipse-temurin-17.0.5_8_1.8.2_2.13.10
# In this example, the sbt build uses credentials from a file, as documented in:
# https://www.scala-sbt.org/1.x/docs/Publishing.html#Credentials
# The file content is set in a variable named SBT_CREDENTIALS in the GitLab project
script:
- echo $SBT_CREDENTIALS > ~/.sbt/.credentials
- sbt publish
# Run the simulation on Gatling Enterprise
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'
Run the simulation weekly
This pipeline will only run when started by a pipeline schedule, which you can configure in your GitLab project, for example to run once a week.
workflow:
rules:
# Execute the pipeline only when scheduled
- if: $CI_PIPELINE_SOURCE == "schedule"
stages:
- load-test
run-gatling-enterprise:
stage: load-test
image:
name: gatlingcorp/enterprise-runner:1
entrypoint: ['']
script:
- gatlingEnterpriseStart
variables:
GATLING_ENTERPRISE_URL: 'http://my-gatling-instance.my-domain.tld'
SIMULATION_ID: '00000000-0000-0000-0000-000000000000'