Run Diffie tests in your Jenkins pipeline
Add Diffie to your Jenkins pipeline to run browser tests on every build. The integration is a shell script using curl and jq — no Jenkins plugins required. Works with Declarative Pipeline, Scripted Pipeline, and Freestyle jobs.
In the Diffie dashboard, go to Settings → API Tokens to generate a token (DIFFIE_TOKEN). Then open the test suite you want to run and copy the Suite ID from the URL or settings page (DIFFIE_SUITE_ID).
In Jenkins, go to Manage Jenkins → Credentials. Add two "Secret text" credentials: one for your Diffie API token (ID: diffie-token) and one for your Suite ID (ID: diffie-suite-id).
Add a Diffie test stage that starts a suite run and polls for results.
pipeline {
agent any
environment {
DIFFIE_TOKEN = credentials('diffie-token')
DIFFIE_SUITE_ID = credentials('diffie-suite-id')
PREVIEW_URL = 'https://your-app.example.com'
}
stages {
stage('Diffie Tests') {
steps {
sh '''
RESPONSE=$(curl -s -X POST \
"https://api.diffie.ai/ci/suites/$DIFFIE_SUITE_ID/execute" \
-H "Authorization: Bearer $DIFFIE_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"baseUrl\": \"$PREVIEW_URL\"}")
RUN_ID=$(echo $RESPONSE | jq -r '.suiteRunId')
RUN_URL=$(echo $RESPONSE | jq -r '.url')
if [ "$RUN_ID" = "null" ] || [ -z "$RUN_ID" ]; then
echo "Failed to start suite run"
echo "$RESPONSE"
exit 1
fi
echo "Suite run started: $RUN_ID"
echo "View results: $RUN_URL"
while true; do
STATUS_RESPONSE=$(curl -s \
"https://api.diffie.ai/ci/suite-runs/$RUN_ID" \
-H "Authorization: Bearer $DIFFIE_TOKEN")
STATUS=$(echo $STATUS_RESPONSE | jq -r '.status')
PASSED=$(echo $STATUS_RESPONSE | jq -r '.passed_tests')
TOTAL=$(echo $STATUS_RESPONSE | jq -r '.total_tests')
echo "Status: $STATUS ($PASSED/$TOTAL passed)"
if [ "$STATUS" = "passed" ]; then
echo "All tests passed!"
exit 0
elif [ "$STATUS" = "failed" ]; then
echo "Tests failed! Details: $RUN_URL"
exit 1
elif [ "$STATUS" = "cancelled" ]; then
echo "Run was cancelled"
exit 1
fi
sleep 10
done
'''
}
}
}
}Trigger a build and verify that Diffie tests run as part of your pipeline. If anything fails, click through to the Diffie dashboard for screenshots and error details.