Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Playwright testing guide covering E2E, component, API, visual, accessibility, and security tests.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
infrastructure-ci-cd/other-providers.md
1# CI: CircleCI, Azure DevOps, and Jenkins23> **When to use**: Running Playwright tests in CI platforms other than GitHub Actions or GitLab.45## Table of Contents671. [Common Commands](#common-commands)82. [Jenkins](#jenkins)93. [CircleCI](#circleci)104. [Azure DevOps](#azure-devops)115. [JUnit Reporter Config](#junit-reporter-config)126. [Platform Comparison](#platform-comparison)137. [Troubleshooting](#troubleshooting)148. [Anti-Patterns](#anti-patterns)1516---1718## Common Commands1920```bash21npx playwright install --with-deps # browsers + OS dependencies22npx playwright test --shard=1/4 # parallel sharding23npx playwright merge-reports ./blob-report # combine shard results24npx playwright test --reporter=dot,html # multiple reporters25```2627## Jenkins2829### Declarative Pipeline3031```groovy32// Jenkinsfile33pipeline {34agent {35docker {36image 'mcr.microsoft.com/playwright:v1.48.0-noble'37args '-u root'38}39}4041environment {42CI = 'true'43HOME = '/root'44npm_config_cache = "${WORKSPACE}/.npm"45}4647options {48timeout(time: 30, unit: 'MINUTES')49disableConcurrentBuilds()50}5152stages {53stage('Install') {54steps {55sh 'npm ci'56}57}5859stage('Test') {60steps {61sh 'npx playwright test'62}63post {64always {65junit allowEmptyResults: true,66testResults: 'results/junit.xml'67archiveArtifacts artifacts: 'pw-report/**',68allowEmptyArchive: true69archiveArtifacts artifacts: 'results/**',70allowEmptyArchive: true71}72}73}74}7576post {77failure {78echo 'Tests failed!'79}80cleanup {81cleanWs()82}83}84}85```8687### Parallel Shards8889```groovy90// Jenkinsfile (sharded)91pipeline {92agent none9394environment {95CI = 'true'96HOME = '/root'97}9899options {100timeout(time: 30, unit: 'MINUTES')101}102103stages {104stage('Test') {105parallel {106stage('Shard 1') {107agent {108docker {109image 'mcr.microsoft.com/playwright:v1.48.0-noble'110args '-u root'111}112}113steps {114sh 'npm ci'115sh 'npx playwright test --shard=1/4'116}117post {118always {119archiveArtifacts artifacts: 'blob-report/**',120allowEmptyArchive: true121}122}123}124stage('Shard 2') {125agent {126docker {127image 'mcr.microsoft.com/playwright:v1.48.0-noble'128args '-u root'129}130}131steps {132sh 'npm ci'133sh 'npx playwright test --shard=2/4'134}135post {136always {137archiveArtifacts artifacts: 'blob-report/**',138allowEmptyArchive: true139}140}141}142stage('Shard 3') {143agent {144docker {145image 'mcr.microsoft.com/playwright:v1.48.0-noble'146args '-u root'147}148}149steps {150sh 'npm ci'151sh 'npx playwright test --shard=3/4'152}153post {154always {155archiveArtifacts artifacts: 'blob-report/**',156allowEmptyArchive: true157}158}159}160stage('Shard 4') {161agent {162docker {163image 'mcr.microsoft.com/playwright:v1.48.0-noble'164args '-u root'165}166}167steps {168sh 'npm ci'169sh 'npx playwright test --shard=4/4'170}171post {172always {173archiveArtifacts artifacts: 'blob-report/**',174allowEmptyArchive: true175}176}177}178}179}180}181}182```183184## CircleCI185186### Basic Pipeline187188```yaml189# .circleci/config.yml190version: 2.1191192executors:193pw:194docker:195- image: mcr.microsoft.com/playwright:v1.48.0-noble196working_directory: ~/app197198jobs:199install:200executor: pw201steps:202- checkout203- restore_cache:204keys:205- deps-{{ checksum "package-lock.json" }}206- run: npm ci207- save_cache:208key: deps-{{ checksum "package-lock.json" }}209paths:210- node_modules211- persist_to_workspace:212root: .213paths:214- node_modules215216test:217executor: pw218parallelism: 4219steps:220- checkout221- attach_workspace:222at: .223- run:224name: Run tests225command: |226npx playwright test --shard=$((CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL227- store_artifacts:228path: pw-report229destination: pw-report230- store_artifacts:231path: results232destination: results233- store_test_results:234path: results/junit.xml235236workflows:237test:238jobs:239- install240- test:241requires:242- install243```244245### Using Orbs246247```yaml248# .circleci/config.yml249version: 2.1250251orbs:252node: circleci/node@latest253254executors:255pw:256docker:257- image: mcr.microsoft.com/playwright:v1.48.0-noble258259jobs:260e2e:261executor: pw262parallelism: 4263steps:264- checkout265- node/install-packages266- run:267name: Run tests268command: npx playwright test --shard=$((CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL269- store_artifacts:270path: pw-report271- store_test_results:272path: results/junit.xml273274workflows:275main:276jobs:277- e2e278```279280## Azure DevOps281282### Basic Pipeline283284```yaml285# azure-pipelines.yml286trigger:287branches:288include:289- main290291pr:292branches:293include:294- main295296pool:297vmImage: "ubuntu-latest"298299variables:300CI: "true"301npm_config_cache: $(Pipeline.Workspace)/.npm302303steps:304- task: NodeTool@0305inputs:306versionSpec: "20.x"307displayName: "Install Node.js"308309- task: Cache@2310inputs:311key: 'npm | "$(Agent.OS)" | package-lock.json'312restoreKeys: |313npm | "$(Agent.OS)"314path: $(npm_config_cache)315displayName: "Cache npm"316317- script: npm ci318displayName: "Install dependencies"319320- script: npx playwright install --with-deps321displayName: "Install browsers"322323- script: npx playwright test324displayName: "Run tests"325326- task: PublishTestResults@2327condition: always()328inputs:329testResultsFormat: "JUnit"330testResultsFiles: "results/junit.xml"331mergeTestResults: true332testRunTitle: "E2E Tests"333displayName: "Publish results"334335- task: PublishPipelineArtifact@1336condition: always()337inputs:338targetPath: pw-report339artifact: pw-report340publishLocation: "pipeline"341displayName: "Upload report"342```343344### With Sharding345346```yaml347# azure-pipelines.yml348trigger:349branches:350include:351- main352353pr:354branches:355include:356- main357358variables:359CI: "true"360361stages:362- stage: Test363jobs:364- job: E2E365pool:366vmImage: "ubuntu-latest"367strategy:368matrix:369shard1:370SHARD: "1/4"371shard2:372SHARD: "2/4"373shard3:374SHARD: "3/4"375shard4:376SHARD: "4/4"377steps:378- task: NodeTool@0379inputs:380versionSpec: "20.x"381382- script: npm ci383displayName: "Install dependencies"384385- script: npx playwright install --with-deps386displayName: "Install browsers"387388- script: npx playwright test --shard=$(SHARD)389displayName: "Run tests (shard $(SHARD))"390391- task: PublishPipelineArtifact@1392condition: always()393inputs:394targetPath: blob-report395artifact: blob-report-$(System.JobPositionInPhase)396displayName: "Upload blob report"397398- stage: Report399dependsOn: Test400condition: always()401jobs:402- job: MergeReports403pool:404vmImage: "ubuntu-latest"405steps:406- task: NodeTool@0407inputs:408versionSpec: "20.x"409410- script: npm ci411displayName: "Install dependencies"412413- task: DownloadPipelineArtifact@2414inputs:415patterns: "blob-report-*/**"416path: all-blob-reports417displayName: "Download blob reports"418419- script: npx playwright merge-reports --reporter=html ./all-blob-reports420displayName: "Merge reports"421422- task: PublishPipelineArtifact@1423inputs:424targetPath: pw-report425artifact: pw-report426displayName: "Upload merged report"427```428429## JUnit Reporter Config430431All platforms benefit from JUnit output for native test result display:432433```typescript434// playwright.config.ts435import { defineConfig } from "@playwright/test";436437export default defineConfig({438reporter: process.env.CI439? [440["dot"],441["html", { open: "never" }],442["junit", { outputFile: "results/junit.xml" }],443]444: [["html", { open: "on-failure" }]],445});446```447448## Platform Comparison449450| Feature | CircleCI | Azure DevOps | Jenkins |451| ----------------- | ----------------------------------------------- | -------------------------------- | ---------------------- |452| Docker support | `docker:` executor | `vmImage` or container jobs | Docker Pipeline plugin |453| Parallelism | `parallelism: N` + `CIRCLE_NODE_INDEX` | `strategy.matrix` | `parallel` stages |454| Artifact upload | `store_artifacts` | `PublishPipelineArtifact@1` | `archiveArtifacts` |455| JUnit integration | `store_test_results` | `PublishTestResults@2` | `junit` step |456| Shard variable | `$((CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL` | Define in matrix: `SHARD: '1/4'` | Hardcode per stage |457| Cache key | `checksum "package-lock.json"` | `Cache@2` with key template | `stash`/`unstash` |458| Secrets | Context + env variables | Variable groups | Credentials plugin |459460## Troubleshooting461462### Jenkins: "Browser closed unexpectedly"463464Running as non-root in container causes sandbox issues.465466```groovy467agent {468docker {469image 'mcr.microsoft.com/playwright:v1.48.0-noble'470args '-u root'471}472}473environment {474HOME = '/root'475}476```477478### CircleCI: "Executable doesn't exist"479480Image version mismatch with `@playwright/test` version. Use `latest` tag or match versions:481482```yaml483docker:484- image: mcr.microsoft.com/playwright:v1.48.0-noble485```486487### Azure DevOps: Test results not showing488489Missing JUnit reporter or `PublishTestResults@2` task:490491```typescript492reporter: [['junit', { outputFile: 'results/junit.xml' }]],493```494495```yaml496- task: PublishTestResults@2497condition: always()498inputs:499testResultsFormat: "JUnit"500testResultsFiles: "results/junit.xml"501```502503### Shard index off by one504505CircleCI's `CIRCLE_NODE_INDEX` is 0-based, Playwright's `--shard` is 1-based:506507```yaml508# CircleCI - add 1509command: npx playwright test --shard=$((CIRCLE_NODE_INDEX + 1))/$CIRCLE_NODE_TOTAL510```511512## Anti-Patterns513514| Anti-Pattern | Problem | Solution |515| ----------------------------------- | ----------------------------------------- | ---------------------------------------------------- |516| Missing `--with-deps` on bare metal | OS libs missing, browser launch fails | Use Playwright Docker image or `--with-deps` |517| No JUnit reporter | CI can't display test results | Add `['junit', { outputFile: 'results/junit.xml' }]` |518| No job timeout | Hung tests consume resources indefinitely | Set explicit timeout (20-30 min) |519| No artifact upload on success | Can't verify passing results | Always upload reports (`condition: always()`) |520| Non-root in container without setup | Permission errors on browser binaries | Run as root or configure permissions |521| Hardcoded shard count | Must update multiple places | Use CI-native variables |522