🎭 Playwright in Jenkins
Playwright in Jenkins: Running Playwright inside Jenkins with a plain Linux agent is like asking a delivery courier to also personally manufacture the truck, the tires, and the f
Running Playwright inside Jenkins with a plain Linux agent is like asking a delivery courier to also personally manufacture the truck, the tires, and the fuel before every single delivery — technically possible, but fragile and slow, and the moment a browser version silently drifts out of sync with the Playwright test runner version, tests start failing for a reason that has nothing to do with your code. Official Docker images solve this by shipping the exact matching browser binaries INSIDE the same image as the test runner, so `agent { docker { image 'mcr.microsoft.com/playwright:v1.42.0-jammy' } }` guarantees the courier arrives with the correct truck already built. The thought-provoking question: if `npm install` already installs Playwright's own browser binaries locally, why bother with a whole separate Docker image at all? Because a shared Jenkins agent runs MANY different jobs with MANY different Playwright versions over time — without an isolated container, one job's browser install can silently overwrite or conflict with another's, exactly the kind of 'works on my machine but not in CI' bug that has no clean local reproduction. Java analogy: this is the same reasoning behind pinning an exact JDK version inside a Docker image for a build agent instead of trusting whatever JDK happens to be globally installed on a shared build server — reproducibility beats convenience. In real QA work, 'browser executable not found' or a mysteriously different rendering result between two CI runs of the identical test is almost always this exact problem, and it disappears the moment the pipeline runs inside a version-pinned container instead of a bare shared agent.
Running Playwright Tests in Jenkins (Best Practice)
Playwright with official Docker image — no browser install needed
Micro Lab: Jenkinsfile pipeline stage completion
Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.
Step by Step: Jenkinsfile pipeline stage completion
Choose execution place with pipeline and agent
Fetch source code with checkout
Run the build/dependency stage
Produce evidence in the test stage
Publish reports and notifications inside post always
Order the Jenkinsfile quality-gate flow.
Try it now in the Jenkins Sandbox on the First Jenkinsfile tab: add a stage that uses an official Docker image like the one above (similar to the existing "Deploy" stage, an echo step is enough) and finish the build green.
🎬 Why Playwright Should Run in a Docker Agent on Jenkins