Skip to content

kushvahasumit/Playwright-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงช Playwright CI/CD Automation with Jenkins, Docker & Allure

Playwright Jenkins Docker AWS


This project implements a real-world CI/CD pipeline for running Playwright UI automation tests using Jenkins, Docker, and Allure reports on AWS EC2. The pipeline automatically runs tests on every push to the main branch and publishes reports reliably.

Check Now!


๐ŸŽฏ Project Goal

  • โœ… Automatically run UI tests on every code push
  • โœ… Use Docker for clean, isolated test execution
  • โœ… Generate reports even when tests fail
  • โœ… Avoid Jenkins / EC2 disk space issues
  • โœ… Follow production-grade CI/CD practices

๐Ÿงฐ Tech Stack

Technology Purpose
Playwright UI Automation
Jenkins CI/CD Orchestration
Docker Containerized Execution
Allure Test Reporting
AWS EC2 + EBS Infrastructure
GitHub Version Control

๐Ÿ”„ CI/CD Flow (High Level)

graph LR
    A[Code Push] --> B[GitHub Webhook]
    B --> C[Jenkins Triggered]
    C --> D[Clone Repository]
    D --> E[Build Docker Image]
    E --> F[Run Tests in Container]
    F --> G[Generate Allure Results]
    G --> H[Publish Report]
    H --> I[Docker Cleanup]
Loading
  1. Code pushed to main branch
  2. GitHub webhook triggers Jenkins
  3. Jenkins clones repository
  4. Docker image is built
  5. Tests run inside Docker container
  6. Allure results are generated
  7. Allure report is published
  8. Docker cleanup runs to save disk space

๐Ÿ”Œ Jenkins Plugins Required

Install from Manage Jenkins โ†’ Plugins:

  • โœ… Git Plugin
  • โœ… Pipeline Plugin
  • โœ… Docker Pipeline Plugin
  • โœ… Allure Jenkins Plugin

๐Ÿ” Credentials & Environment Management

All sensitive values are stored in Jenkins Credentials, not in code.

Examples:

  • Application URLs
  • Login usernames
  • Passwords / tokens

Injected into Docker using environment variables.

โœ… Secure
โŒ No hardcoded secrets


๐Ÿณ Docker Setup for Jenkins

Problem

Jenkins cannot run Docker commands by default.

Fix

Give Docker permission to Jenkins user:

sudo usermod -aG docker jenkins
sudo systemctl restart jenkins

Verify:

docker ps

๐Ÿ’พ Disk Space Problem

Issue Faced

  • Jenkins built-in node uses limited root storage
  • Docker images + reports quickly fill disk
  • Pipelines start failing with space errors

Solution Used

  1. Attach EBS volume to EC2
  2. Use it for Jenkins workspace
  3. Clean Docker after every pipeline run
post {
  always {
    sh 'docker system prune -af || true'
  }
}

This keeps Jenkins stable long-term.


๐Ÿงช Test Execution Strategy

  • โœ… Tests run inside Docker
  • โœ… Container removed after execution (--rm)
  • โœ… No leftover state between builds
  • โœ… Same environment every run

๐Ÿ“Š Reporting Strategy

Playwright Report

  • Generated after each test run
  • Helpful for debugging failures

Allure Report

  • Generated even if tests fail
  • Must be published in post { always {} }
post {
  always {
    allure(results: [[path: 'allure-results']])
  }
}

๐Ÿšซ Allure Permission Error

Error

AccessDeniedException: allure-results/testrun.json

Root Cause

Docker creates files as root, Jenkins cannot write to them.

Fix

sudo chown -R jenkins:jenkins /var/lib/jenkins/workspace
sudo chmod -R 755 /var/lib/jenkins/workspace

๐Ÿ–ผ Playwright Snapshot Issue

Problem

Snapshots created locally on Windows/Mac:

*-chromium-win32.png

CI runs on Linux:

*-chromium-linux.png

Playwright treats them as different โ†’ tests fail every time.

Correct Fix (Industry Standard)

  1. Generate snapshots on Linux:

  2. Commit Linux snapshots only:

*-chromium-linux.png

๐Ÿš€ CI Triggering

Recommended Way

  • GitHub Webhook
    • Instant trigger on push
    • Industry standard

Alternative

  • SCM polling (not recommended for production)

๐Ÿง  Challenges Faced (Interview Gold)

Challenge Resolution
Docker permission issues in Jenkins Added jenkins user to docker group
EC2 disk getting full Attached EBS volume + Docker cleanup
Allure report not generating on failure Used post { always {} } block
Snapshot mismatch across OS Generated Linux snapshots only
Jenkins workspace permission errors Fixed ownership and permissions

โœ… Project Status

  • โœ” Fully automated CI
  • โœ” Stable Docker execution
  • โœ” Reliable Allure reporting
  • โœ” Production-ready setup

๐Ÿ“ฃ Usage

This project reflects real QA / SDET CI pipelines used in companies and is suitable for:

  • ๐ŸŽฏ QA Automation roles
  • ๐ŸŽฏ SDET interviews
  • ๐ŸŽฏ DevOps + QA hybrid roles

โญ Star this repo if you find it helpful!

About

Playwright automation tests using Jenkins, Docker, and Allure reports on AWS EC2.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

โšก