playwright: [Bug] - Firefox with Jenkins inside Docker does not work
Context: Project: https://github.com/APAODUQS/playwright-demo Playwright image: mcr.microsoft.com/playwright:v1.20.1-focal Jenkins Server version: 2.277.4
#Jenkinsfile
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright:v1.20.1-focal' } }
stages {
stage('e2e-tests') {
steps {
sh 'npm install'
sh 'npm run test -- --project Chrome --grep @playwright'
}
}
}
}
Describe the problem:
I am trying to run the tests from a jenkins build as the documentation indicates: https://playwright.dev/docs/ci#jenkins, but when I try to run it with the previous configuration, with the playwright docker image I get this error:

Then, when I run:
sh '''
npm install
npx playwright install chrome
npm run test -- --project Chrome --grep @playwright
'''
I get the error:

Then I tried to run it with tue command npx playwright install:
sh '''
npm install
npx playwright install
npm run test -- --project Chrome --grep @playwright
'''
And I get the same first error.
I have tried a lot of things but they still are not working. Could you help me or suggest me how I could run it?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (10 by maintainers)
Try this: https://github.com/microsoft/playwright/discussions/13716#discussioncomment-3192464
Thanks @APAODUQS! Is that output from a run in a container? If not (and theirs a display), remove the
xvfb-runbit—that’s only needed if there isn’t a display available already. That looks like a different error from https://github.com/microsoft/playwright/issues/13230#issuecomment-1086195132.Since there are now several confirmations that it works for some Jenkins Docker configurations and the surface area for configuring Jenkins and its agents is large, folks in the Jenkins community will likely be better able to help you troubleshoot.
Thanks for your patience, and feel free to post back what you find!
@spursbob @APAODUQS I’m failing to repro the issue on my Jenkins instance. /tmp is writeable and the tests (headful and headless for firefox) all pass:
Here is the full code (Jenkinsfile and test code for the pipeline above): https://github.com/rwoll/jenkins-playground/tree/8ecb7cc77328b5f484483accd421b29909dfe765
Please try running that repo on your Jenkins instance and let us know if it passes or fails (in the same or different way from the issue reported here). If it passes (and is therefore not a repro), then we’ll need you to link us to a repro repo from you in order to debug further.
We’re using
os.tmpdir()in our Node code when choosing these tmp directories. If that’s not writable on yours Jenkins installation, that seems like it would break more than just Playwright. Perhaps the Jenkins agent is not configured properly and there are some overall permissions issues?Thanks for your patience! Happy Jenkins debugging!
You and I seem to be in the same boat. My hunch is we can’t write to the /tmp dir to create the profile. See “-profile /tmp/playwright_firefoxdev_profile-7i2bQF” in your output.
I’m evaluating Playwright for my organisation and thinking of dropping Playwright as an option which is a shame as it’s my favourite.
I got this:
Do you get the same error when running:
I think PWDEBUG=console is running in headed mode so masking your actual issue.
Are you running firefox in headful mode? This error message usually indicates a headful browser is running without a display.
In CI, you’ll want to put
xvfb-runin front of your commands so a virtual display is used:Ref: https://playwright.dev/docs/ci#running-headed
Awesome!
You can enable tracing and view the trace of one of your failed FFox runs. Alterntively, focus one test, and run with
DEBUG="pw:*"env var set to get a dump of logs. Share here (after skimming them for anything sensitive)! If you’re getting an error at a specific part of your test, please include the line(s) and the exact error message.I don’t have expertise with Jenkins, nor do I have a Jenkins instance handy to test. I suspect Jenkins is running your commands inside the docker container as Jenkins user, so it can’t do the root commands needed for the npx playwright install.
Can you try the following where you have Jenkins break up the building of the test image and actually running the tests?
DockerfileJenkinsfileI’ll cross post to in the community chat as I’m not a Jenkins user!
looks correct. Can you add
whoamito see what user Jenkins is running in your container?