CI/CD Integration
Run tests automatically on every push.
CI/CD Integration
Integrate Plaintest with your CI/CD pipeline to run tests automatically on every push.
Overview
With CI/CD integration:
- You push code to your repository
- Your CI system notifies Plaintest
- We run your promoted tests against the new code
- Results are reported back to your PR
Supported CI/CD Systems
- GitHub Actions (recommended)
- GitLab CI
- Bitbucket Pipelines
- Any system that can make HTTP requests
GitHub Actions Setup
1. Create an API Key
- Go to Settings > API Keys
- Click Create API Key
- Copy the key (you'll only see it once)
2. Add the Secret
In your GitHub repo:
- Go to Settings > Secrets and variables > Actions
- Click New repository secret
- Name:
PLAINTEST_API_KEY - Value: Your API key
3. Create the Workflow
Create .github/workflows/plaintest.yml:
name: Plaintest
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Trigger Plaintest
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.PLAINTEST_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "your-project-id",
"branch": "${{ github.ref_name }}",
"commit": "${{ github.sha }}"
}' \
https://console.plaintest.dev/api/v1/test-runs
4. Configure Branch URL Mapping
Map branches to different URLs:
| Branch | URL |
|--------|-----|
| main | https://myapp.com |
| develop | https://staging.myapp.com |
| * | https://preview-{branch}.myapp.com |
Configure in Project Settings > Branch URLs.
GitLab CI Setup
Create .gitlab-ci.yml:
plaintest:
stage: test
script:
- |
curl -X POST \
-H "Authorization: Bearer $PLAINTEST_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"projectId\": \"your-project-id\",
\"branch\": \"$CI_COMMIT_REF_NAME\",
\"commit\": \"$CI_COMMIT_SHA\"
}" \
https://console.plaintest.dev/api/v1/test-runs
only:
- main
- develop
- merge_requests
Add PLAINTEST_API_KEY in Settings > CI/CD > Variables.
Bitbucket Pipelines Setup
Create bitbucket-pipelines.yml:
pipelines:
default:
- step:
name: Plaintest
script:
- |
curl -X POST \
-H "Authorization: Bearer $PLAINTEST_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"projectId\": \"your-project-id\",
\"branch\": \"$BITBUCKET_BRANCH\",
\"commit\": \"$BITBUCKET_COMMIT\"
}" \
https://console.plaintest.dev/api/v1/test-runs
Add PLAINTEST_API_KEY in Repository settings > Pipelines > Repository variables.
Webhook Notifications
Configure webhooks to receive test results:
- Go to Settings > Webhooks
- Add your webhook URL
- Select events to receive:
test_run.completedtest_run.failed
Webhook Payload
{
"event": "test_run.completed",
"testRun": {
"id": "abc123",
"status": "passed",
"projectId": "your-project-id",
"branch": "main",
"commit": "abc123",
"results": {
"total": 10,
"passed": 9,
"failed": 1
}
}
}
GitHub Commit Status
For GitHub projects, we can update commit status:
- Install the Plaintest GitHub App
- Grant access to your repository
- Test results will appear as commit checks
Best Practices
- Run on PRs: Catch issues before merging
- Use branch mapping: Test against the right environment
- Set up notifications: Get alerted on failures
- Review results: Check the Plaintest dashboard for details
Troubleshooting
Tests not triggering
- Verify the API key is correct
- Check the workflow is running (GitHub Actions tab)
- Ensure the project ID matches
Wrong URL being tested
- Check branch URL mapping
- Verify the branch name is correct
Authentication failures
- Ensure secrets are configured in Plaintest
- Check that the test URL is accessible