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:

  1. You push code to your repository
  2. Your CI system notifies Plaintest
  3. We run your promoted tests against the new code
  4. 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

  1. Go to Settings > API Keys
  2. Click Create API Key
  3. Copy the key (you'll only see it once)

2. Add the Secret

In your GitHub repo:

  1. Go to Settings > Secrets and variables > Actions
  2. Click New repository secret
  3. Name: PLAINTEST_API_KEY
  4. 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:

  1. Go to Settings > Webhooks
  2. Add your webhook URL
  3. Select events to receive:
    • test_run.completed
    • test_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:

  1. Install the Plaintest GitHub App
  2. Grant access to your repository
  3. Test results will appear as commit checks

Best Practices

  1. Run on PRs: Catch issues before merging
  2. Use branch mapping: Test against the right environment
  3. Set up notifications: Get alerted on failures
  4. 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

Next Steps