How to Integrate Playwright with Jenkins – Complete Step-by-Step Guide with Examples (2026)

Introduction: Why Jenkins Remains One of the Most Popular CI/CD Tools for Playwright Automation in 2026

Continuous Integration and Continuous Delivery (CI/CD) have become essential practices in modern software development. Every code change should be automatically built, tested, and validated before reaching production. This reduces manual effort, catches bugs early, and speeds up software releases.

Among the many CI/CD platforms available today, Jenkins remains one of the most widely adopted automation servers. Its open-source ecosystem, extensive plugin library, and flexibility make it a preferred choice for organizations ranging from startups to large enterprises.

When Jenkins is integrated with Playwright, automated browser tests can run every time developers commit code, create pull requests, or trigger scheduled builds. Jenkins can automatically install dependencies, execute Playwright tests, generate HTML reports, archive screenshots and videos, and notify QA teams of test results.

If you’re learning how to integrate Playwright with Jenkins, you’re developing a practical DevOps and automation testing skill expected from QA Automation Engineers, SDETs, Selenium engineers transitioning to Playwright, developers, and DevOps engineers.

Whether you are:

  • A QA Automation Engineer
  • An SDET
  • A Selenium engineer transitioning to Playwright
  • A software testing student
  • A DevOps engineer
  • A web developer
  • Preparing for Playwright or Jenkins interviews

Learning Playwright Jenkins integration will help you build enterprise-ready automation pipelines that support continuous testing and faster software delivery.

In this guide, you’ll learn:

  • What is Jenkins?
  • Why integrate Playwright with Jenkins?
  • Prerequisites for integration
  • Create a Playwright project
  • Configure Jenkins
  • Run Playwright tests automatically
  • Generate HTML reports
  • Archive screenshots, videos, and traces
  • Create Jenkins Pipelines
  • CI/CD best practices
  • Troubleshooting
  • Interview questions
  • FAQs

What Is Jenkins?

Jenkins is an open-source automation server used to build, test, and deploy software automatically.

It helps development and QA teams automate repetitive tasks such as:

  • Building applications
  • Running automated tests
  • Generating reports
  • Deploying applications
  • Monitoring software quality

Jenkins supports thousands of plugins, making it one of the most flexible CI/CD tools available.


Simple Definition

Jenkins is an automation server that continuously builds, tests, and deploys applications using configurable pipelines.


Jenkins Architecture

A typical Jenkins environment consists of:

  • Jenkins Server
  • Jenkins Agents (Nodes)
  • Source Code Repository (GitHub, GitLab, Bitbucket)
  • Build Pipeline
  • Test Automation Framework
  • Reporting Tools

Architecture Diagram

Developer

     │

     ▼

 Git Repository

     │

     ▼

 Jenkins Server

     │

 ┌───┴──────────────┐

 ▼                  ▼

Agent 1         Agent 2

 │                  │

Playwright      Playwright

Tests           Tests

 │                  │

 └──────┬───────────┘

        ▼

 HTML Reports

 Screenshots

 Videos

 Trace Files


Why Integrate Playwright with Jenkins?

Playwright automates browser testing, while Jenkins automates execution.

Together they enable continuous testing throughout the software development lifecycle.

Benefits for QA Teams

Integrating Playwright with Jenkins helps teams:

  • Execute automated tests after every commit
  • Run regression suites automatically
  • Validate pull requests
  • Reduce manual testing effort
  • Improve release confidence
  • Support continuous integration
  • Generate HTML reports automatically
  • Enable faster defect detection

Real-World Example

Imagine an online banking application.

Every developer commit triggers:

  • Application build
  • Playwright automation
  • Cross-browser testing
  • HTML report generation
  • Screenshot capture
  • Notification to the QA team

This ensures defects are identified immediately instead of during manual regression testing.


Prerequisites Before Integration

Before integrating Playwright with Jenkins, ensure the following software is installed and configured.


1. Install Node.js

Verify installation:

node -v

npm -v

Expected Output

v22.x.x

10.x.x


2. Install Playwright

Create a Playwright project.

mkdir playwright-jenkins-demo

cd playwright-jenkins-demo

npm init -y

npm init playwright@latest

This installs:

  • Playwright Test Runner
  • Browser binaries
  • Sample tests
  • HTML Reporter
  • Configuration files

3. Install Jenkins

Download Jenkins from the official website and complete the installation.

Start the Jenkins service and access the dashboard:

http://localhost:8080

[Screenshot Placeholder: Jenkins Dashboard Home Page]


4. Configure the Git Repository

Push your Playwright project to GitHub (or another Git provider).

Example:

git init

git add .

git commit -m “Initial Playwright project”

git remote add origin https://github.com/your-org/playwright-project.git

git push -u origin main

Jenkins will later clone this repository to execute your automation suite.


5. Install Required Jenkins Plugins

Navigate to:

Manage Jenkins → Plugins

Install the following plugins:

  • Git Plugin
  • Pipeline Plugin
  • HTML Publisher Plugin
  • NodeJS Plugin
  • Workspace Cleanup Plugin
  • JUnit Plugin (optional)

These plugins enable Git integration, pipeline execution, HTML report publishing, Node.js management, workspace cleanup, and test result visualization.


Step-by-Step Guide: How to Integrate Playwright with Jenkins

Step 1: Create a Playwright Project

Create a sample Playwright test.

import { test, expect } from ‘@playwright/test’;

test(‘Homepage Test’, async ({ page }) => {

    await page.goto(‘https://playwright.dev’);

    await expect(page).toHaveTitle(/Playwright/);

});

Explanation

This test:

  • Opens the Playwright website
  • Waits for the page to load
  • Verifies the page title

Expected Output

The test passes successfully and generates execution results that Jenkins will later collect.


Step 2: Configure playwright.config.ts

Enable HTML reporting and artifact collection.

import { defineConfig } from ‘@playwright/test’;

export default defineConfig({

    reporter: ‘html’,

    use: {

        screenshot: ‘only-on-failure’,

        video: ‘retain-on-failure’,

        trace: ‘retain-on-failure’

    }

});

Explanation

This configuration enables:

  • HTML reports
  • Screenshots for failed tests
  • Videos for failed tests
  • Trace files for debugging

These artifacts can later be archived by Jenkins for easy access.

Step 3: Create a Jenkins Freestyle Project

Once Jenkins is installed and your Playwright project is available in Git, create a Jenkins Freestyle project to automate test execution.

Navigate to:

Jenkins Dashboard

New Item

Freestyle Project

Enter a project name:

Playwright Automation

Click OK.

[Screenshot Placeholder: Create Jenkins Freestyle Project]


Step 4: Configure Source Code Management

Under Source Code Management, select Git.

Repository URL:

https://github.com/your-org/playwright-project.git

If your repository is private:

  • Add Git credentials
  • Select the saved credentials

Expected Result

Every Jenkins build downloads the latest Playwright automation project.


Step 5: Configure Build Triggers

Jenkins supports multiple ways to trigger Playwright automation.

Option 1: Build Manually

Click:

Build Now

Useful during development.


Option 2: Poll SCM

Enable:

Poll SCM

Example schedule:

H/5 * * * *

Explanation

Jenkins checks Git every five minutes.

If code changes are detected, Jenkins automatically starts the Playwright build.


Option 3: GitHub Webhook

Enable:

GitHub hook trigger for GITScm polling

Benefits

Every Git commit immediately starts Playwright automation.

This is the recommended approach for modern CI/CD pipelines.


Step 6: Configure Build Steps

Under Build, select:

Execute Windows Batch Command

Windows:

npm install

npx playwright install

npx playwright test

Linux/macOS:

npm ci

npx playwright install –with-deps

npx playwright test

Explanation

This performs:

  • Install project dependencies
  • Install Playwright browsers
  • Execute the complete Playwright automation suite

Expected Output

Jenkins Console Output:

Installing dependencies…

Running Playwright Tests…

15 Passed

2 Failed

HTML Report Generated


Step 7: Generate HTML Reports Automatically

Since the HTML Reporter is already configured inside playwright.config.ts, every Jenkins execution automatically generates:

playwright-report/

Example configuration:

import { defineConfig } from ‘@playwright/test’;

export default defineConfig({

    reporter: ‘html’

});

Expected Result

Every Jenkins build creates an interactive Playwright HTML report.


Step 8: Archive Reports After Every Build

Install the HTML Publisher Plugin.

Navigate to:

Post-build Actions

Publish HTML Reports

Configuration:

HTML Directory

playwright-report

Index page

index.html

Report Title

Playwright HTML Report

Expected Result

After every Jenkins build:

  • HTML Report
  • Screenshots
  • Videos
  • Trace Files

become available directly from the Jenkins dashboard.

[Screenshot Placeholder: Jenkins HTML Report Configuration]


Step 9: Archive Screenshots, Videos, and Trace Files

Navigate to:

Post-build Actions

Archive the Artifacts

Artifacts:

playwright-report/**

test-results/**

test-results/**/*.png

test-results/**/*.webm

test-results/**/*.zip

Explanation

Jenkins preserves:

  • HTML reports
  • Screenshots
  • Videos
  • Trace Viewer files

even after the build completes.

Practical Scenario

If a test fails overnight, QA engineers can download the screenshots and replay the Trace Viewer without rerunning the suite.


Jenkins Build Workflow

Developer Pushes Code

          │

          ▼

Git Repository

          │

          ▼

Jenkins Pulls Latest Code

          │

          ▼

npm install

          │

          ▼

Playwright Browser Installation

          │

          ▼

Execute Tests

          │

          ▼

Generate HTML Report

          │

          ▼

Archive Reports

          │

          ▼

Build Completed


Creating a Jenkins Pipeline Using a Jenkinsfile

While Freestyle Projects are simple to configure, most enterprise teams use Jenkins Pipelines because they are version-controlled and stored with the application code.

Create a file named:

Jenkinsfile

Example declarative pipeline:

pipeline {

    agent any

    stages {

        stage(‘Checkout’) {

            steps {

                checkout scm

            }

        }

        stage(‘Install Dependencies’) {

            steps {

                sh ‘npm ci’

                sh ‘npx playwright install –with-deps’

            }

        }

        stage(‘Run Playwright Tests’) {

            steps {

                sh ‘npx playwright test’

            }

        }

        stage(‘Publish HTML Report’) {

            steps {

                publishHTML(target: [

                    reportDir: ‘playwright-report’,

                    reportFiles: ‘index.html’,

                    reportName: ‘Playwright HTML Report’

                ])

            }

        }

    }

    post {

        always {

            archiveArtifacts artifacts: ‘playwright-report/**’

            archiveArtifacts artifacts: ‘test-results/**’

        }

    }

}

Explanation

This Jenkins Pipeline:

  • Checks out the latest source code
  • Installs dependencies
  • Installs Playwright browsers
  • Executes Playwright tests
  • Publishes the HTML report
  • Archives reports, screenshots, videos, and trace files

Expected Output

After every successful build:

  • Jenkins Pipeline completes successfully
  • HTML report is published
  • Screenshots are archived
  • Videos are archived
  • Trace files are available for download

Screenshot Placeholder

+———————————————+

| Jenkins Pipeline                            |

+———————————————+

| ✔ Checkout                                  |

| ✔ Install Dependencies                      |

| ✔ Run Playwright Tests                      |

| ✔ Publish HTML Report                       |

| ✔ Archive Artifacts                         |

+———————————————+

[Screenshot Placeholder: Successful Jenkins Pipeline Execution]

Running Playwright Tests Automatically on Every Git Commit

One of the biggest advantages of integrating Playwright with Jenkins is that automation tests can execute automatically whenever code changes are pushed to your repository. This enables continuous testing and provides immediate feedback to developers.

Jenkins supports several methods to trigger Playwright automation.


1. GitHub Webhooks

GitHub Webhooks provide real-time integration between GitHub and Jenkins.

Whenever a developer pushes code:

  • GitHub sends an HTTP request to Jenkins.
  • Jenkins automatically starts the Playwright pipeline.
  • Test execution begins immediately.

Configure GitHub Webhook

Open your GitHub repository.

Navigate to:

Settings

Webhooks

Add Webhook

Payload URL:

http://your-jenkins-server/github-webhook/

Content Type:

application/json

Select:

Just the push event

Save the webhook.


Configure Jenkins

Inside your Jenkins project, enable:

Build Triggers

GitHub hook trigger for GITScm polling

Workflow

Developer Pushes Code

          │

          ▼

GitHub Repository

          │

          ▼

GitHub Webhook

          │

          ▼

Jenkins Pipeline

          │

          ▼

Playwright Tests

          │

          ▼

HTML Report Generated

Benefits

  • Instant execution
  • Faster feedback
  • Fully automated pipeline
  • No manual intervention

2. Scheduled Builds (CRON)

Some organizations prefer running Playwright automation at scheduled times.

Example:

  • Every night
  • Every weekend
  • Before production deployment

Configure:

Build Triggers

Build periodically

Example CRON:

H 2 * * *

Explanation

The pipeline executes every day at approximately 2:00 AM.

Practical Scenario

Nightly regression testing.

Every night Jenkins automatically:

  • Downloads latest code
  • Executes Playwright tests
  • Generates HTML reports
  • Archives screenshots
  • Sends notifications

3. Poll SCM Configuration

Instead of using GitHub Webhooks, Jenkins can periodically check the repository for changes.

Enable:

Build Triggers

Poll SCM

Example schedule:

H/10 * * * *

Explanation

Jenkins checks Git every 10 minutes.

If changes are detected:

  • Build starts automatically
  • Playwright executes
  • Reports are generated

Difference

GitHub WebhookPoll SCM
InstantPeriodic
More efficientMore server polling
RecommendedLegacy approach

Real-World Jenkins + Playwright CI/CD Workflow

A typical enterprise automation pipeline looks like this:

Developer Commits Code

          │

          ▼

Git Repository (GitHub)

          │

          ▼

Webhook Trigger

          │

          ▼

Jenkins Pipeline Starts

          │

          ▼

Checkout Latest Source Code

          │

          ▼

Install Node.js Dependencies

          │

          ▼

Install Playwright Browsers

          │

          ▼

Execute Cross-Browser Tests

          │

          ▼

Generate HTML Report

          │

          ▼

Capture Screenshots

Videos

Trace Files

          │

          ▼

Archive Artifacts

          │

          ▼

Send Build Notification


Cross-Browser Execution in Jenkins

Playwright supports running tests across multiple browsers during Jenkins execution.

Example configuration:

import { defineConfig, devices } from ‘@playwright/test’;

export default defineConfig({

    projects: [

        {

            name: ‘Chromium’,

            use: {

                …devices[‘Desktop Chrome’]

            }

        },

        {

            name: ‘Firefox’,

            use: {

                …devices[‘Desktop Firefox’]

            }

        },

        {

            name: ‘WebKit’,

            use: {

                …devices[‘Desktop Safari’]

            }

        }

    ]

});

Expected Result

Jenkins executes:

  • Chromium tests
  • Firefox tests
  • WebKit tests

during the same pipeline.


Running Tests in Parallel Using Jenkins Agents

Enterprise Jenkins installations often contain multiple agents.

Example:

Jenkins Master

        │

 ┌──────┼─────────┐

 ▼      ▼         ▼

Agent1 Agent2  Agent3

 │      │         │

Chrome Firefox WebKit

Each Jenkins agent executes a portion of the automation suite.

Benefits

  • Faster regression testing
  • Better CPU utilization
  • Shorter release cycles
  • Scalable automation

Using Environment Variables

Avoid hard-coding URLs and credentials.

Example:

use: {

    baseURL: process.env.BASE_URL

}

Pipeline example:

environment {

    BASE_URL = “https://qa.example.com”

}

Benefits

One pipeline can execute against:

  • Development
  • QA
  • Staging
  • Production (read-only)

without modifying the Playwright framework.


Best Practices for Jenkins Integration

1. Store Dependencies Efficiently

Use:

npm ci

instead of:

npm install

Benefits:

  • Faster builds
  • Reproducible dependency installation
  • Better CI/CD performance

2. Use Environment Variables

Store:

  • URLs
  • API Keys
  • Usernames
  • Passwords

inside Jenkins Credentials or environment variables.

Never hard-code sensitive information.


3. Run Tests in Parallel

Configure Playwright workers:

workers: 4

Leverage Jenkins agents to distribute execution across multiple machines.


4. Keep Test Data Isolated

Avoid using shared test accounts.

Instead:

  • Generate unique users
  • Create test data dynamically
  • Clean up data after execution

This prevents failures caused by parallel execution.


5. Archive Reports and Logs

Archive:

  • HTML Reports
  • Screenshots
  • Videos
  • Trace Files
  • Jenkins Console Logs

These artifacts make debugging significantly easier.


Enterprise Project Structure

playwright-project/

tests/

pages/

utils/

fixtures/

reports/

playwright-report/

test-results/

Jenkinsfile

playwright.config.ts

Keeping reports, test artifacts, and pipeline files organized improves maintainability and makes onboarding easier for new team members.

Common Jenkins Integration Issues and Troubleshooting Tips

Even after configuring Jenkins and Playwright correctly, you may encounter issues related to dependencies, permissions, browser installation, or pipeline execution. Understanding these common problems will help you build stable and reliable CI/CD pipelines.


Issue 1: Node.js Not Found

Cause

Jenkins cannot locate the Node.js executable.

Example error:

node: command not found

or

‘npm’ is not recognized as an internal or external command

Solution

Install Node.js on the Jenkins server.

Verify installation:

node -v

npm -v

Configure the NodeJS Plugin:

Manage Jenkins

Global Tool Configuration

NodeJS

Expected Result

Jenkins successfully executes:

npm ci

without errors.


Issue 2: Playwright Browser Installation Failure

Cause

Playwright browsers have not been installed on the Jenkins machine.

Example error:

Executable doesn’t exist

Please run:

npx playwright install

Solution

Install browsers before running tests.

npx playwright install –with-deps

For Linux agents:

npx playwright install –with-deps

This installs:

  • Chromium
  • Firefox
  • WebKit
  • Required operating system dependencies

Issue 3: Permission Denied Errors

Cause

The Jenkins user does not have permission to execute scripts or access project files.

Example error:

Permission denied

Solution

Grant execution permissions.

Linux:

chmod +x node_modules/.bin/playwright

Also verify:

  • Workspace permissions
  • Jenkins service account permissions
  • File ownership

Issue 4: Jenkins Workspace Cleanup Issues

Cause

Old reports, screenshots, or cached files remain in the Jenkins workspace.

This may cause:

  • Incorrect reports
  • Old screenshots
  • Outdated test results

Solution

Install the Workspace Cleanup Plugin.

Configure:

Delete workspace before build starts

Or use the pipeline step:

cleanWs()

Benefits

Every pipeline starts with a clean workspace, preventing stale artifacts from affecting the current build.


Issue 5: HTML Reports Not Generated

Cause

The HTML Reporter is not configured or the report directory is not being archived.

Solution

Ensure playwright.config.ts contains:

reporter: ‘html’

Verify the report folder:

playwright-report/

Publish the report using the HTML Publisher Plugin or archive it as a build artifact.


Issue 6: Pipeline Execution Failures

Cause

Pipeline stages fail because of:

  • Incorrect Jenkinsfile syntax
  • Missing dependencies
  • Invalid environment variables
  • Network connectivity issues

Solution

Review the Jenkins console log to identify the failing stage.

Example pipeline:

stage(‘Run Tests’) {

    steps {

        sh ‘npx playwright test’

    }

}

Verify each stage independently before combining them into a complete pipeline.


Workflow Diagram

Developer Pushes Code

          │

          ▼

GitHub Repository

          │

          ▼

Jenkins Pipeline

          │

          ▼

Install Dependencies

          │

          ▼

Install Browsers

          │

          ▼

Execute Playwright Tests

          │

          ▼

Generate HTML Report

          │

          ▼

Archive Reports

          │

          ▼

Build Completed


Playwright + Jenkins vs GitHub Actions vs Azure DevOps vs GitLab CI

FeatureJenkinsGitHub ActionsAzure DevOpsGitLab CI
Open Source✅ Yes❌ No❌ NoCommunity Edition
Self Hosted✅ YesLimitedYesYes
Pipeline as Code✅ Jenkinsfile✅ YAML✅ YAML✅ YAML
Plugin EcosystemExcellentModerateGoodGood
Playwright SupportExcellentExcellentExcellentExcellent
HTML Report PublishingEasyEasyEasyEasy
Parallel ExecutionYesYesYesYes
Cross-Browser TestingExcellentExcellentExcellentExcellent
Enterprise AdoptionVery HighHighVery HighHigh

Why Choose Jenkins for Playwright?

Jenkins continues to be a popular CI/CD choice because it offers:

  • Free and open-source licensing
  • Large plugin ecosystem
  • Flexible pipeline configuration
  • Excellent integration with Git repositories
  • Support for distributed builds using agents
  • Easy artifact publishing
  • Mature enterprise adoption

For organizations that require complete control over their CI/CD infrastructure, Jenkins remains an excellent platform for running Playwright automation.


Playwright Jenkins Interview Questions with Answers

1. What is Jenkins?

Jenkins is an open-source automation server used to build, test, and deploy software through automated CI/CD pipelines.


2. Why integrate Playwright with Jenkins?

Integrating Playwright with Jenkins enables automatic execution of browser tests after every code change, improving software quality and reducing manual testing effort.


3. Which file is used to define a Jenkins Pipeline?

A Jenkinsfile defines a declarative or scripted Jenkins pipeline.


4. How do you execute Playwright tests in Jenkins?

Run the following command in a build step or pipeline stage:

npx playwright test


5. How do you publish Playwright HTML reports in Jenkins?

Use the HTML Publisher Plugin to publish the playwright-report directory after test execution.


6. How can Playwright tests be triggered automatically in Jenkins?

Common triggering methods include:

  • GitHub Webhooks
  • Poll SCM
  • Scheduled CRON builds
  • Manual builds

7. What artifacts should be archived after execution?

Archive:

  • HTML reports
  • Screenshots
  • Videos
  • Trace files
  • Test results
  • Console logs

These artifacts simplify debugging and maintain historical execution records.


FAQs – How to Integrate Playwright with Jenkins

Q1. What is how to integrate Playwright with Jenkins?

It is the process of connecting a Playwright automation framework with Jenkins so tests execute automatically during CI/CD pipelines.


Q2. How do I get started with how to integrate Playwright with Jenkins?

Install Node.js, Playwright, and Jenkins, configure a Playwright project, create a Jenkins job or Jenkinsfile, and execute npx playwright test.


Q3. What are the benefits of how to integrate Playwright with Jenkins?

Benefits include:

  • Automated regression testing
  • Continuous integration
  • Faster feedback
  • HTML report generation
  • Artifact archiving
  • Cross-browser execution
  • Improved software quality

Q4. Is how to integrate Playwright with Jenkins suitable for beginners?

Yes. Jenkins provides both Freestyle Projects and Pipeline as Code, making it accessible for beginners while supporting advanced enterprise workflows.


Q5. Can Playwright generate HTML reports in Jenkins?

Yes. Configure the HTML Reporter in playwright.config.ts, execute your tests, and publish the generated playwright-report directory using the HTML Publisher Plugin.

Leave a Comment

Your email address will not be published. Required fields are marked *