Integration · CI/CD · via REST API

Masked and synthetic test data in Jenkins pipelines

Add a stage that refreshes the test database before your tests run. The stage calls the Synthesized REST API with a key from Jenkins credentials, waits for the workflow to finish, and fails the build if it doesn't.

Jenkins and Synthesized at a glance

There is no Jenkins plugin; this pattern uses the documented REST API.

How it connectsA sh step runs a script that starts a workflow with POST /external/api/v1/workflow/{id}/run and polls GET /workflow-run/{id}.
SecretsThe access key is a Jenkins Secret text credential, bound with withCredentials and masked in the log.
Agent needscurl, jq and HTTPS access to Governor.
Schedulingtriggers { cron('H 2 * * 1-5') } for a weekday refresh, or run it on every build.
StatusWorks through the REST API. Jenkins 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 credential

Generate an access key for a dedicated Governor user and store it in Jenkins as a Secret text credential, for example synthesized-access-key.

3. Commit the script

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

4. Add the stage

Put the data stage before the test stage, as in the Jenkinsfile below.

Example Jenkinsfile

A declarative pipeline that refreshes data on weekday nights and before every test run. Replace the Governor URL and workflow ID with your own.

Jenkinsfile

pipeline {
agent any
options { disableConcurrentBuilds() }
triggers { cron('H 2 * * 1-5') }
environment {
GOVERNOR_URL = 'https://governor.example.internal'
WORKFLOW_ID = '42'
}
stages {
stage('Prepare test data') {
steps {
withCredentials([string(credentialsId: 'synthesized-access-key', variable: 'GOVERNOR_ACCESS_KEY')]) {
sh 'sh ./scripts/run-synthesized-workflow.sh'
}
}
}
stage('Run tests') {
steps {
sh 'mvn -B 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 Jenkins and Synthesized

Is there a Jenkins plugin?

No. A pipeline stage calls the Synthesized REST API, so it works with any Jenkins 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 keep the key secret?

Store it as a Secret text credential and bind it with withCredentials. Jenkins masks bound secrets in the build log, on a best-effort basis, so don't echo them.

Does it work with freestyle jobs?

Yes. Add an Execute shell build step that runs the script, and bind the credential with the build environment option for secret text.

What about Windows agents?

The calls are plain HTTPS, so a PowerShell step with Invoke-RestMethod works the same way: start the run, poll the status, read the logs on failure.

How do I stop two builds refreshing the same database?

Add disableConcurrentBuilds() to the pipeline options, or give each environment its own Synthesized workflow and output database.

Try it on one Jenkins job

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

Updated November 2026

All product names, including Jenkins, are trademarks of their respective owners.