Integration · CI/CD · via REST API

Masked and synthetic test data in GitLab CI/CD

Add a job that refreshes the test database before your test stage. The job calls the Synthesized REST API with a masked CI/CD variable, waits for the workflow, and fails the pipeline if the data isn't ready.

GitLab and Synthesized at a glance

There is no GitLab component; this pattern uses the documented REST API.

How it connectsA job runs a script that starts a workflow with POST /external/api/v1/workflow/{id}/run and polls GET /workflow-run/{id}.
SecretsGOVERNOR_ACCESS_KEY as a masked and hidden, protected CI/CD variable.
Orderingneeds makes the test job wait for the data job; resource_group stops two refreshes running at once.
SchedulingPipeline schedules, with rules on $CI_PIPELINE_SOURCE.
StatusWorks through the REST API. GitLab isn't named in the Synthesized docs; the API calls are.

Set it up

1. Build the workflow in Governor

Create the masking, subsetting or generation workflow and run it once by hand. Note its workflow ID.

2. Add the variables

Under Settings › CI/CD › Variables, add GOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY (masked and hidden, protected).

3. Commit the script

Add run-synthesized-workflow.sh to the repository. It exits non-zero if the run fails, which fails the job.

4. Add the jobs and a schedule

Add the two jobs below, then create a pipeline schedule for the nightly refresh.

Example .gitlab-ci.yml

The data job runs on scheduled and manually started pipelines; the test job waits for it when it runs.

.gitlab-ci.yml

stages:
- test-data
- test
 
prepare-test-data:
stage: test-data
image: alpine:3.20
resource_group: test-database
before_script:
- apk add --no-cache curl jq
script:
- sh ./scripts/run-synthesized-workflow.sh
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "web"
 
run-tests:
stage: test
image: node:22
needs:
- job: prepare-test-data
optional: true
script:
- npm ci
- npm test

scripts/run-synthesized-workflow.sh

#!/bin/sh
# run-synthesized-workflow.sh: start a Synthesized workflow and wait for it.
# Needs GOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY; uses curl and jq.
set -eu
API="$GOVERNOR_URL/external/api/v1"
AUTH="X-Access-Key: $GOVERNOR_ACCESS_KEY"
TIMEOUT_SEC="${TIMEOUT_SEC:-1800}"
 
RUN=$(curl -sSf -X POST -H "$AUTH" "$API/workflow/$WORKFLOW_ID/run")
RUN_ID=$(printf '%s' "$RUN" | jq -r '.workflow_run_id')
echo "Started workflow run $RUN_ID"
 
WAITED=0
while [ "$WAITED" -lt "$TIMEOUT_SEC" ]; do
RUN=$(curl -sSf -H "$AUTH" "$API/workflow-run/$RUN_ID")
STATUS=$(printf '%s' "$RUN" | jq -r '.workflow_run_status')
case "$STATUS" in
COMPLETED) echo "Test data ready"; exit 0 ;;
FAILED|STOPPED)
echo "Run $RUN_ID ended as $STATUS: $(printf '%s' "$RUN" | jq -r '.error_message')"
curl -sS -H "$AUTH" "$API/workflow-run/$RUN_ID/logs" | tail -n 50
exit 1 ;;
esac
sleep 10
WAITED=$((WAITED + 10))
done
echo "Timed out after $TIMEOUT_SEC seconds; stopping workflow $WORKFLOW_ID"
curl -sS -X POST -H "$AUTH" "$API/workflow/$WORKFLOW_ID/stop" || true
exit 1

Things to know

Use a dedicated key

An access key carries the permissions of the Governor user who generated it. Create a user that can reach only the workflows this pipeline runs, generate the key as that user, and give it a short expiry: keys are chosen from 1 hour to a year, and the docs say they can't yet be revoked.

One output database per environment

Two runs can't write to the same output database at the same time. If parallel pipelines or branches need data, give each environment its own workflow or output database.

Where the data goes

Workers read the source, mask, subset or generate, and write the target. Database contents stay with the workers and aren't sent to Governor, which, like the pipeline, only sees run status, logs and configuration. Run Synthesized on-premises, including air-gapped, and the data never leaves your environment; it is also available as SaaS.

Questions about GitLab and Synthesized

Is there a GitLab plugin?

No. A CI/CD job calls the Synthesized REST API, so it works with any GitLab setup that can reach your Governor over HTTPS. You need an HTTP client (the examples use curl and jq), the Governor URL, a workflow ID and an access key.

How do I protect the access key?

Add it under Settings › CI/CD › Variables with Visibility set to Masked and hidden, and tick Protect variable so only pipelines on protected branches and tags can read it. Masking needs a single-line value of at least 8 characters.

How do I refresh data every night?

Create a pipeline schedule for the branch. The example's rules run the data job on scheduled and manually started pipelines.

How do I stop two pipelines refreshing the same database?

Give the job a resource_group. GitLab then runs only one job in that group at a time, which matches Synthesized's rule that two runs can't write to the same output database at once.

Can I use GitLab-hosted runners?

Only if Governor can be reached from the internet. For an internal Governor, use a runner inside your network.

Try it on one pipeline

Bring one GitLab pipeline that waits on test data, and see a Synthesized workflow refresh it before the tests run.

Updated November 2026

GitLab is a trademark of GitLab Inc. All other product names are trademarks of their respective owners.