Skip to content

Jenkins

Jenkins pipelines run Playwright with npx playwright test, publish JUnit XML, and archive HTML reports — often inside Docker agents with preinstalled browsers.

Declarative Pipeline

Use Node agent or Docker image mcr.microsoft.com/playwright:v1.49.0-jammy with browsers preinstalled — skips install step.

Configure reporter: [['junit', { outputFile: 'results.xml' }]] for Jenkins test result trends.

pipeline {
  agent { docker { image 'mcr.microsoft.com/playwright:v1.49.0-jammy' } }
  stages {
    stage('Test') {
      steps {
        sh 'npm ci && npx playwright test'
      }
    }
  }
  post {
    always {
      junit 'results.xml'
      archiveArtifacts 'playwright-report/**'
    }
  }
}

Pin Docker image tag to match @playwright/test version.

Jenkins Tips

Parallel stages for shard 1/2/3
Credentials for TEST_PASSWORD
HTML Publisher plugin for report
  • Official Playwright Docker images include browsers + deps.
  • Archive test-results for traces on failure.
  • Set CI=true in environment block.
  • Parallelize with matrix or multiple stages.

Jenkins + Playwright

Integration checklist.

Item Recommendation
Agent Playwright Docker image
Results JUnit reporter XML
Artifacts playwright-report + test-results
Secrets Jenkins credentials → env
Version pin Image tag = npm package version
Parallel Shard across executors

Why Docker Agents

Playwright Docker images eliminate 'works on agent X' drift — consistent glibc, fonts, and browser builds across Jenkins workers.

HTML Report Publisher

Use Jenkins HTML Publisher plugin pointed at playwright-report/index.html so stakeholders browse results inside Jenkins.

Common Mistakes

  • Mismatch between Docker image Playwright version and package.json.
  • No JUnit upload — Jenkins shows green but tests failed.
  • Bare metal agent missing libgtk — use install-deps or Docker.
  • Huge archived artifacts without retention policy.

Key Takeaways

  • Use official Playwright Docker images in Jenkins.
  • JUnit reporter integrates with Jenkins test UI.
  • Archive HTML report and traces post-build.
  • Pin versions across npm and Docker.

Pro Tip

Label Jenkins agents playwright and restrict E2E jobs to them — avoids running browser installs on every generic worker.