For the complete documentation index, see llms.txt. This page is also available as Markdown.

Harness

Running Playwright tests on Harness CI with Currents reporting and parallel sharding

This guide explains how to run Playwright tests on Harness Continuous Integration and report results to Currents. It follows Harness NextGen pipeline patterns (Run steps, stage parallelism, secrets).

Prerequisites

Currents

Harness

  • A CI pipeline with a Build (CI) stage

  • A Docker registry connector that can pull your Playwright image (for example mcr.microsoft.com/playwright). Replace YOUR_DOCKER_CONNECTOR in the examples with your connector reference (for example account.harnessImageRegistry or your org’s Docker Hub connector).

Store the Record Key as a Harness secret

  1. In Harness, create an encrypted text secret at the appropriate scope (project, org, or account).

  2. Use a stable identifier (Harness derives it from the name). Example identifier: currents_record_key.

  3. Reference it only by identifier in expressions, not the display name. See Add and reference text secrets.

Application configuration

Use the same Playwright + Currents setup as other CI providers.

playwright.config.ts (reporter):

currents.config.ts:

CI Build ID (mandatory on Harness)

You must provide CURRENTS_CI_BUILD_ID (environment variable or reporter config). It is a required input for correct Currents behavior on Harness — not optional.

Without a stable, explicit value:

  • Each parallel shard may get its own ID → multiple runs instead of one combined run

  • Reruns may reuse or collide with IDs → stale or rejected uploads — see the CI Build ID FAQ

The value must be:

  • Unique per pipeline execution (each execution gets its own Currents run)

  • Identical across all parallel Playwright shards in the same execution (shards merge into one run)

  • Different when you retry the same logical build, when you need a fresh run — see CI Build ID

Harness resolves expressions before the step runs. Common choices:

Approach
Expression (example)
Notes

Execution only

<+pipeline.executionId>

Unique per execution; confirm behavior for re-runs in your Harness edition

Execution + sequence

Concatenate <+pipeline.executionId> with <+pipeline.sequenceId> using + or .concat()

See Harness variables; helps separate retries when sequenceId changes

Compose multi-part IDs with the concatenation patterns documented under Harness variables (for example combining <+pipeline.identifier>, <+pipeline.executionId>, and <+pipeline.sequenceId>).

Option A — Single Run step (no parallelism)

Add a Run step in your CI stage. Set Container Registry to your Docker connector and Image to a Playwright image tag that matches your @playwright/test version.

  • Replace YOUR_CURRENTS_PROJECT_ID with your project ID, or use a pipeline variable (for example <+pipeline.variables.currents_project_id>).

  • Replace currents_record_key with your secret’s identifier.

Use stage-level parallelism so Harness runs multiple copies of the stage. Playwright’s --shard is 1-based; Harness parallel indices are 0-based, so use HARNESS_NODE_INDEX + 1 for the shard index.

Do not rely on Harness split_tests for Playwright unless you intentionally drive a custom split; native sharding matches the rest of Currents’ CI docs and keeps setup simple.

  • Tune parallelism and maxConcurrency per best practices for looping strategies.

  • CURRENTS_CI_BUILD_ID is mandatory — the same value must reach every shard (the <+pipeline.executionId> expression above resolves identically for all parallel instances of the same execution).

Environment variables reference

Variable
Required
Description

CURRENTS_PROJECT_ID

Yes

Currents project ID from the dashboard

CURRENTS_RECORD_KEY

Yes

Record key; inject via <+secrets.getValue("SECRET_IDENTIFIER")> (or org/account-scoped variant)

CURRENTS_CI_BUILD_ID

Yes (mandatory)

Required on Harness. Stable ID shared by all shards in one execution; must change appropriately on retries — see CI Build ID

CI

Optional

Set to true so tools behave as in CI

HARNESS_NODE_INDEX

Parallel only

<+strategy.iteration> — 0-based shard index

HARNESS_NODE_TOTAL

Parallel only

<+strategy.iterations> — must match parallelism

Optional — Pipeline or stage variables

You can define pipeline or stage variables for non-secret settings (for example project ID) and reference them with expressions such as <+pipeline.variables.currents_project_id>. Precedence for environment variables in Harness is step > stage > pipeline. See Variables (open-source YAML) and Harness variables (expressions).

Harness Open Source / GitOps pipeline YAML

If you use the open-source pipeline schema (kind: pipeline), environment variables are often declared under spec.options.envs (pipeline-wide) or spec.envs on a ci stage, and Run steps use spec.container and spec.script. The Currents requirements are the same: include CURRENTS_CI_BUILD_ID (mandatory), other CURRENTS_* variables, and npx playwright test with optional --shard. Map them to your schema per CI stage reference.

Further reading

Got stuck configuring CI? Reach out to Support.

Last updated

Was this helpful?