Setup CI/CD Integration
Integrate BugBrain tests into your CI/CD pipeline to automatically run tests on every code change.
Prerequisites
- ✓ BugBrain account with Growth+ plan
- ✓ At least one test plan created
- ✓ CI/CD platform access (GitHub, GitLab, or Jenkins)
Step 1: Generate CI/CD Token
1
Go to Project Settings
In BugBrain dashboard, click Settings for your project
2
Find CI/CD Integration
Scroll to CI/CD Integration section
3
Generate Token
Click 'Generate CI/CD Token' button
4
Copy Credentials
Copy Webhook URL and Webhook Secret to safe location
You’ll get:
- Webhook URL:
https://api.bugbrain.tech/webhooks/ci/... - Webhook Secret:
secret_abc123xyz... - Test Plan ID:
tp_prod_xyz789
⚠️
Save these securely. Never commit to git or share publicly.
Step 2: Add to CI/CD Platform
For GitHub Actions
- Go to Repository Settings → Secrets and variables → Actions
- Create three secrets:
BUGBRAIN_WEBHOOK_URLBUGBRAIN_WEBHOOK_SECRETBUGBRAIN_TEST_PLAN_ID
- Paste values from BugBrain
- Create
.github/workflows/bugbrain.yml:
name: BugBrain Tests
on: [push, pull_request]
jobs:
bugbrain:
runs-on: ubuntu-latest
steps:
- name: Run BugBrain Tests
run: |
curl -X POST "${{ secrets.BUGBRAIN_WEBHOOK_URL }}" \
-H "X-Bugbrain-Secret: ${{ secrets.BUGBRAIN_WEBHOOK_SECRET }}" \
-d '{"test_plan_id": "'${{ secrets.BUGBRAIN_TEST_PLAN_ID }}'"}'For GitLab CI
- Go to Settings → CI/CD → Variables
- Add three protected variables:
BUGBRAIN_WEBHOOK_URLBUGBRAIN_WEBHOOK_SECRETBUGBRAIN_TEST_PLAN_ID
- Update
.gitlab-ci.yml:
bugbrain_tests:
stage: test
script:
- curl -X POST "$BUGBRAIN_WEBHOOK_URL" \
-H "X-Bugbrain-Secret: $BUGBRAIN_WEBHOOK_SECRET" \
-d '{"test_plan_id": "'$BUGBRAIN_TEST_PLAN_ID'"}'For Jenkins
- Go to Manage Jenkins → Manage Credentials
- Add secret text credential:
bugbrain-webhook-secret - Create Jenkinsfile:
pipeline {
agent any
environment {
BUGBRAIN_URL = 'https://api.bugbrain.tech/webhooks/ci/...'
BUGBRAIN_SECRET = credentials('bugbrain-webhook-secret')
}
stages {
stage('BugBrain Tests') {
steps {
sh 'curl -X POST "$BUGBRAIN_URL" -H "X-Bugbrain-Secret: $BUGBRAIN_SECRET" -d "{}"'
}
}
}
}Step 3: Test the Integration
- Commit and push your pipeline file to trigger tests
- Check CI/CD platform for execution status
- View BugBrain results in project executions list
- Verify test ran successfully
Step 4: Configure Triggers
Trigger on Specific Events
GitHub: Push to main branch and PRs
on:
push:
branches: [main, develop]
pull_request:GitLab: Merge requests and protected branches
only:
- merge_requests
- mainJenkins: After build completes
post {
always {
sh 'curl -X POST ...'
}
}Step 5: Handle Test Results
Fail Pipeline on Test Failures
Add result checking:
# Get execution status
STATUS=$(curl -s "https://api.bugbrain.tech/api/v1/executions/{execution_id}/status" \
-H "Authorization: Bearer $API_KEY")
# Fail if tests failed
FAILED=$(echo $STATUS | jq -r '.failed_tests')
if [ "$FAILED" -gt 0 ]; then
exit 1
fiPost Results to PR
GitHub:
gh pr comment $PR_NUMBER -b "✅ BugBrain Tests Passed: $PASSED_COUNT/$TOTAL_COUNT"GitLab:
curl -X POST "https://gitlab.example.com/api/v4/projects/$PROJECT_ID/merge_requests/$MR_IID/notes" \
-d '{"body":"✅ BugBrain tests passed"}'Troubleshooting
Tests Not Running
- Verify webhook URL is correct (no typos)
- Check CI/CD secrets are set
- Confirm test plan exists and isn’t archived
- View webhook logs in BugBrain (Settings → Webhooks)
Pipeline Timeout
- Increase timeout: GitHub
timeout-minutes: 20, GitLabtimeout: 15 minutes - Check if BugBrain service is degraded
- Verify network connectivity between CI/CD and BugBrain
Results Not Showing
- Confirm API key has read permissions
- Check execution ID is correct
- Verify polling endpoint
/api/v1/executions/{id}/status
Next Steps: Configure test failure notifications in Slack or Teams to stay informed of test results.