> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdino.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright Jenkins Pipeline Setup

> Stream Playwright results from Jenkins pipelines to TestDino live, with sharded parallel stages grouped into one run.

Set up a Jenkins pipeline that streams Playwright test results to TestDino during the run and view aggregated analytics, failure analysis, and flaky test detection on your dashboard.

## Prerequisites

* A <a href="https://app.testdino.com" target="_blank" rel="noopener noreferrer">TestDino account <Icon icon="arrow-up-right-from-square" size={12} /></a> with a project created
* A TestDino API key ([Generate API Keys](/guides/generate-api-keys))
* Jenkins instance with pipeline support
* A Playwright test project (or clone the <a href="https://github.com/testdino-hq/TestDino-Example" target="_blank" rel="noopener noreferrer">TestDino Example Repository <Icon icon="arrow-up-right-from-square" size={12} /></a> to get started)
* `@testdino/playwright` installed and configured in `playwright.config.ts|js|mjs`:

```bash theme={null}
npm install @testdino/playwright
```

```typescript playwright.config.ts theme={null}
import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['@testdino/playwright', {
      token: process.env.TESTDINO_TOKEN,
      serverUrl: "https://reporter.testdino.com",
    }],
  ],
});
```

## Set Up Your API Key

Store your TestDino API key as a Jenkins credential so it is available to your pipeline without exposing it in logs or config files.

1. Open Jenkins
2. Go to **Manage Jenkins → Credentials**
3. Open the store where you want to add the secret
4. Click **Add Credentials**
5. Set **Kind** to `Secret text`
6. Paste your TestDino API key into **Secret**
7. Set the **ID** to `TESTDINO_TOKEN`
8. Click **Save**

<Warning>
  **Warning**

  Never commit your API key directly in pipeline files. Always use Jenkins credentials. Secret credentials are not exposed in build logs.
</Warning>

## Basic Pipeline Config

For a simple setup without sharding, run your tests with the `TESTDINO_TOKEN` credential in scope. Results stream to TestDino during the run, so no separate upload stage is needed.

<Accordion title="Jenkinsfile: Basic pipeline">
  ```groovy Jenkinsfile theme={null}
  pipeline {
      agent {
          docker {
              image 'mcr.microsoft.com/playwright:v1.59.1-noble'
              args '-u root'
          }
      }

      environment {
          CI = 'true'
          HOME = '/root'
          TESTDINO_TOKEN = credentials('TESTDINO_TOKEN')
          TESTDINO_SERVER_URL = 'https://reporter.testdino.com'
      }

      stages {
          stage('Install') {
              steps {
                  sh 'npm ci'
              }
          }

          stage('Run tests with TestDino') {
              steps {
                  sh 'npx playwright test'
              }
          }
      }
  }
  ```
</Accordion>

<Tip>
  **Tip**

  The `credentials()` function maps the Jenkins credential to the `TESTDINO_TOKEN` environment variable `@testdino/playwright` reads. Results stream live even when tests fail, so failures land on the dashboard without a `post.always` upload stage.
</Tip>

## Sharded Test Runs

For larger test suites, Jenkins parallel stages split tests across multiple shards. Each shard streams its own results, and TestDino groups them into one run when they share a `ci-run-id`.

### How it works

1. Jenkins runs Playwright across 4 shards using parallel stages
2. Each shard streams its results to TestDino during the run
3. Every shard passes the same `--ci-run-id` so TestDino merges them into a single run
4. No merge or upload stage runs after the shards finish

### Full sharded config

<Accordion title="Jenkinsfile: Sharded pipeline">
  ```groovy Jenkinsfile theme={null}
  pipeline {
      agent {
          docker {
              image 'mcr.microsoft.com/playwright:v1.59.1-noble'
              args '-u root'
          }
      }

      environment {
          CI = 'true'
          HOME = '/root'
          TESTDINO_TOKEN = credentials('TESTDINO_TOKEN')
          TESTDINO_SERVER_URL = 'https://reporter.testdino.com'
      }

      options {
          timeout(time: 45, unit: 'MINUTES')
          disableConcurrentBuilds()
      }

      stages {
          stage('Checkout') {
              steps {
                  checkout scm
                  stash includes: '**/*', name: 'source'
              }
          }

          stage('Run Playwright shards') {
              parallel {
                  stage('Shard 1') {
                      steps {
                          dir('shard-1') {
                              unstash 'source'
                              sh 'npm ci'
                              sh 'npx tdpw test --ci-run-id "$BUILD_TAG" -- --shard=1/4'
                          }
                      }
                  }
                  stage('Shard 2') {
                      steps {
                          dir('shard-2') {
                              unstash 'source'
                              sh 'npm ci'
                              sh 'npx tdpw test --ci-run-id "$BUILD_TAG" -- --shard=2/4'
                          }
                      }
                  }
                  stage('Shard 3') {
                      steps {
                          dir('shard-3') {
                              unstash 'source'
                              sh 'npm ci'
                              sh 'npx tdpw test --ci-run-id "$BUILD_TAG" -- --shard=3/4'
                          }
                      }
                  }
                  stage('Shard 4') {
                      steps {
                          dir('shard-4') {
                              unstash 'source'
                              sh 'npm ci'
                              sh 'npx tdpw test --ci-run-id "$BUILD_TAG" -- --shard=4/4'
                          }
                      }
                  }
              }
          }
      }
  }
  ```
</Accordion>

### Key details

| Config Block                        | What It Does                                                                         |
| :---------------------------------- | :----------------------------------------------------------------------------------- |
| `docker { image ... }`              | Uses the official Playwright Docker image with all browsers pre-installed            |
| `parallel { stage('Shard N') }`     | Runs 4 shard stages in parallel                                                      |
| `--shard=1/4` through `--shard=4/4` | Passes the shard value directly to Playwright                                        |
| `--ci-run-id "$BUILD_TAG"`          | Groups all shards into one run on the dashboard                                      |
| `credentials('TESTDINO_TOKEN')`     | Maps the Jenkins credential to the environment variable `@testdino/playwright` reads |

Set the `ciRunId` reporter option in `playwright.config` to `$BUILD_TAG` if you prefer running `npx playwright test` directly instead of `npx tdpw test`.

### Pipeline execution

After the pipeline runs, Jenkins shows each stage in the pipeline graph with pass, fail, or unstable status. Each shard streams its results, and TestDino merges them into one run.

<img src="https://tdstorageus.blob.core.windows.net/public/docs/installation-and-setup/ci-setup/playwright-jenkins/jenkins-testrun-pipeline-execution.webp" alt="Jenkins pipeline stages view showing Checkout and parallel Playwright shard stages streaming results to TestDino" />

### Results in TestDino

The test run appears in your TestDino dashboard with full failure details, flaky detection, and trend data as tests complete.

<img src="https://tdstorageus.blob.core.windows.net/public/docs/installation-and-setup/ci-setup/playwright-jenkins/jenkins-uploaded-testdino-testrunscreen.webp" alt="TestDino Test Runs dashboard showing streamed results from Jenkins pipeline with pass/fail counts and AI Insights" />

## Troubleshooting

<AccordionGroup>
  <Accordion title="Results not appearing on the dashboard">
    Confirm `@testdino/playwright` is in your `playwright.config` `reporter` array and the `TESTDINO_TOKEN` credential is mapped in the `environment` block. Results stream during the run, so no separate upload stage is required.
  </Accordion>

  <Accordion title="Sharded runs show up as separate runs">
    Pass the same `--ci-run-id "$BUILD_TAG"` (or `ciRunId` reporter option) to every shard. Different values create one run per shard.
  </Accordion>

  <Accordion title="TESTDINO_TOKEN not available in pipeline">
    Confirm the credential is set in **Manage Jenkins → Credentials** with the ID `TESTDINO_TOKEN`. Use `credentials('TESTDINO_TOKEN')` in the `environment` block to map it to an environment variable.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="CI Optimization" icon="gauge-high" href="/guides/playwright-ci-optimization">
    Reduce CI time with smart reruns
  </Card>

  <Card title="Environment Mapping" icon="code-branch" href="/guides/environment-mapping">
    Route test results to Dev, Staging, or Production by branch
  </Card>

  <Card title="Integrations" icon="puzzle-piece" href="/integrations/overview">
    Connect Slack, Jira, Linear, Asana, and more
  </Card>

  <Card title="TestDino MCP" icon="plug" href="/mcp/overview">
    Access test results and fix issues with AI agents
  </Card>
</CardGroup>
