CI/CD Integration
Integrate retestr.ai into your Continuous Integration / Continuous Deployment pipeline to catch visual regressions automatically on every pull request or deployment.
Overview
Triggering a test run from your CI pipeline involves two steps:
- Generate an API Key: Obtain credentials from the Dashboard.
- Trigger the Run: Make an HTTP request to our API from your CI script.
1. Generate an API Key
- Go to Settings > API Keys in your Organization.
- Click Create New Key.
- Give it a name (e.g., "GitHub Actions").
- Select the
run:writescope (allows triggering runs). - Copy the key immediately. You won't be able to see it again.
2. Trigger the Run
You can trigger a run using curl or any HTTP client.
Endpoint: POST https://retestr.ai/api/runs
Headers:
x-api-key: Your API Key.Content-Type:application/json.
Body Parameters:
projectId: The ID of the project to run (found in Project Settings URL).branch: (Optional) The git branch name (e.g.,main,feature/login).commit: (Optional) The git commit hash.ciBuildId: (Optional) Link back to your CI build.
Example: GitHub Actions
Add this step to your .github/workflows/test.yml:
- name: Trigger Visual Tests
run: |
curl -X POST https://retestr.ai/api/runs \
-H "x-api-key: ${{ secrets.RETESTR_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "proj_12345",
"branch": "${{ github.ref_name }}",
"commit": "${{ github.sha }}"
}'
Example: Generic Shell Script
#!/bin/bash
API_KEY="your_api_key"
PROJECT_ID="proj_12345"
response=$(curl -s -X POST https://retestr.ai/api/runs \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"projectId\": \"$PROJECT_ID\",
\"branch\": \"$(git rev-parse --abbrev-ref HEAD)\"
}")
echo "Run triggered: $response"
Blocking Builds
By default, the API call triggers the run asynchronously and returns immediately. If you want your CI pipeline to fail if the visual tests fail, you will need to poll the run status.
(Coming Soon: A dedicated CLI tool to handle waiting and exit codes automatically).