Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't run Puppeteer within Pipelines

Kirk-Platform-FE
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 14, 2024

My bitbucket-pipelines.yml :

pipelines:
default:
- step:
name: Install Chrome
image: node:latest
caches:
- node
script:
- apt-get update
- apt-get install -y wget gnupg xvfb
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
- apt-get update
- apt-get install -y google-chrome-stable
- ln -sf /usr/bin/google-chrome /usr/bin/chrome
- chmod 755 /usr/bin/chrome
- google-chrome --version
- which google-chrome
- node --version
- npm --version
- npm install
- npm run json-web
- cat assets/web.json

Puppeteer lanch code:

 
const browser = await puppeteer.launch({

executablePath: `/usr/bin/google-chrome`,

args: [

'--no-sandbox',

'--disable-setuid-sandbox',

'--disable-dev-shm-usage',

'--disable-accelerated-2d-canvas',

'--no-first-run',

'--no-zygote',

'--single-process', // <- this one doesn't works in Windows

'--disable-gpu'

],

headless: true,

// 设置视窗的宽高

defaultViewport: {

width: 1920,

height: 1080,

},

});
When run the pipeline, error occured:
QQ20240715-114255@2x.png
The chrome is installed successfully, but cant't find the DOM in a page.
It works well locally.

2 answers

3 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2024

Hi @Kirk-Platform-FE and welcome to the community!

When you say it works locally, are you running this directly on your machine?

If so, your machine's environment is different from the environment where the Pipelines build runs. Pipelines builds run in Docker containers based on the image you specify in your yml file (in your case, it's node:latest).

The best way to troubleshoot a failed build in an environment similar to Pipelines, is to debug it locally with Docker by following this guide:

I suggest following this guide and ensuring you reset the local repo to the correct commit hash (Step 2) and use the correct Docker image hash (Step 3). If possible, I also suggest following the guide on a Linux machine to rule out any issues that may have to do with different platforms.

If you follow these steps and the build still fails, it is not an issue with Pipelines and you need to debug further and figure out why the build doesn't run in this container.

If you follow our troubleshooting guide and the build succeeds, you can create a ticket with the support team and provide:

  • the URL of the failed build In Pipelines
  • the output of all commands when you troubleshoot the build locally as per our guide

You can create a ticket via https://support.atlassian.com/contact/#/, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product. When you are asked to provide the workspace URL, please make sure you enter the URL of the workspace that is on a paid billing plan to proceed with ticket creation.

Please feel free to reach out if you have any questions.

Kind regards,
Theodora

1 vote
Nicolas Grossi
Banned
July 14, 2024

@Kirk-Platform-FE Welcome! If you run this not in pipeline but manually it runs successfully ?

 

Nicolas

Kirk-Platform-FE
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 14, 2024

Yes! It words well locally if I delete this line:

executablePath: '/usr/bin/google-chrome'

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events