> ## 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 Bitbucket Pipelines Setup

> Stream Playwright results from Bitbucket Pipelines to TestDino live, with sharded runs grouped into one run.

<Callout icon="book-open" color="#3B82F6">
  **What you'll learn**

  * How to stream Playwright results from Bitbucket Pipelines to TestDino
  * How to group sharded test runs into a single run
  * How to store the TESTDINO\_TOKEN as a secured repository variable
</Callout>

Bitbucket Pipelines runs your CI from a `bitbucket-pipelines.yml` file in the root of your repository. This guide covers a basic run and a parallel sharded setup that streams results to TestDino during the run.

## Prerequisites

Before setting up, ensure you have:

* 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))
* A Bitbucket repository with Pipelines enabled
* 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 secured repository variable so it is available to your pipeline without exposing it in `bitbucket-pipelines.yml`.

1. Open your repository in Bitbucket
2. Go to **Repository settings**
3. Under **Pipelines**, click **Repository variables**
4. Click **Add variable**
5. Set **Name** to `TESTDINO_TOKEN`
6. Paste your TestDino API key into **Value**
7. Tick **Secured** so the value is masked in logs
8. Click **Add**

<Tip>
  **Tip**

  Use **Repository variables** for a project-specific token, or **Workspace variables** when you want the same token available across every repository in your workspace.
</Tip>

## Basic Pipeline Config

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

<Accordion title="bitbucket-pipelines.yml — Basic pipeline">
  ```yaml bitbucket-pipelines.yml theme={null}
  image: mcr.microsoft.com/playwright:v1.59.1-noble

  definitions:
    caches:
      npm: ~/.npm

  pipelines:
    default:
      - step:
          name: Run tests with TestDino
          caches:
            - npm
          script:
            - npm ci
            - npx playwright test
  ```
</Accordion>

<Tip>
  **Tip**

  Set `TESTDINO_TOKEN` as a **Secured** repository variable so `@testdino/playwright` reads it during the run. Results stream live even when tests fail, so failures land on the dashboard without a separate upload step.
</Tip>

## Sharded Test Runs

For large test suites, run shards in parallel. Each shard streams its own results, and TestDino groups them into one run when they share a `ci-run-id`.

### How it works

1. Each shard runs Playwright with `--shard=<n>/<total>` in its own Bitbucket step
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 step runs after the shards finish

### Full sharded config

<Accordion title="bitbucket-pipelines.yml — Sharded pipeline">
  ```yaml bitbucket-pipelines.yml theme={null}
  image: mcr.microsoft.com/playwright:v1.59.1-noble

  definitions:
    caches:
      npm: ~/.npm

  pipelines:
    default:
      - parallel:
          - step:
              name: Shard 1
              caches:
                - npm
              script:
                - npm ci
                - npx tdpw test --ci-run-id "$BITBUCKET_BUILD_NUMBER" -- --shard=1/4
          - step:
              name: Shard 2
              caches:
                - npm
              script:
                - npm ci
                - npx tdpw test --ci-run-id "$BITBUCKET_BUILD_NUMBER" -- --shard=2/4
          - step:
              name: Shard 3
              caches:
                - npm
              script:
                - npm ci
                - npx tdpw test --ci-run-id "$BITBUCKET_BUILD_NUMBER" -- --shard=3/4
          - step:
              name: Shard 4
              caches:
                - npm
              script:
                - npm ci
                - npx tdpw test --ci-run-id "$BITBUCKET_BUILD_NUMBER" -- --shard=4/4
  ```
</Accordion>

### Key details

| Detail                                  | Notes                                                                                                                             |
| :-------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| `parallel:`                             | Bitbucket runs every step under this block at the same time, on separate runners.                                                 |
| `--shard=<n>/4`                         | Passes the shard value directly to Playwright.                                                                                    |
| `--ci-run-id "$BITBUCKET_BUILD_NUMBER"` | Groups all shards into one run on the dashboard.                                                                                  |
| `TESTDINO_TOKEN`                        | Read from the **Secured** repository variable you added earlier. Masked in logs.                                                  |
| `TESTDINO_SERVER_URL`                   | Set as a repository variable to `https://reporter.testdino.com`, or keep `serverUrl` in the `playwright.config` reporter options. |

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

### Pipeline execution

After the pipeline runs, Bitbucket shows each shard step in the pipeline view. 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-bitbucket/bitbucket-testrun-pipeline-execution.webp" alt="Bitbucket Pipelines build view showing shard steps streaming Playwright 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-bitbucket/bitbucket-uploaded-testdino-testrunscreen.webp" alt="TestDino Test Runs dashboard showing streamed results from Bitbucket Pipelines 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 `TESTDINO_TOKEN` is available to the step. Results stream during the run, so no separate upload step is required.
  </Accordion>

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

  <Accordion title="TESTDINO_TOKEN not available in the pipeline">
    Open **Repository settings → Pipelines → Repository variables** and confirm a variable named exactly `TESTDINO_TOKEN` exists and is marked **Secured**. Variable names are case-sensitive.
  </Accordion>
</AccordionGroup>

## Next Steps

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

  <Card title="Branch Mapping" icon="code-branch" href="/platform/organizations/settings">
    Map branches to environments for organized test runs
  </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>
