Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running unlighthouse in Jenkins Chromium error #217

Open
thidayatullah opened this issue May 17, 2024 · 0 comments
Open

Running unlighthouse in Jenkins Chromium error #217

thidayatullah opened this issue May 17, 2024 · 0 comments

Comments

@thidayatullah
Copy link

thidayatullah commented May 17, 2024

Describe the bug

I write a go module to read data from google sheets, and run unlighthouse audit before writing the report back into the sheet.
It works fine on my computer. Now I want to run it from Jenkins job but I keep getting errors.

The Jenkins agent run on a container and doesn't have Chrome installed. So I added this into my unlighthouse.config.ts:
(In my local computer I don't use this config because it runs well with my System Chrome Browser)

export default {
    chrome: {
      useSystem: false,
    },
};

It installed Chromium successfully but failed to launch it with this error:

Error: Unable to launch browser for worker, error message: Failed to launch the browser process!
/root/.unlighthouse/chromium/linux-1095492/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory

If I run the module in my computer using the config above, it launch a bunch of Chromium app and then get stuck on this step:
ℹ The url config has been provided with 1 paths for scanning. Disabling sitemap, robots, sampling and crawler.
So I just commented out the config if I want to run it locally.

Here is the bash script I run on Jenkins:

#!/bin/bash
export NVM_DIR="${WORKSPACE}/.nvm"
export NVM_VERSION="18.19.0"

# Create the .nvm directory if it doesn't exist
if [ ! -d "$NVM_DIR" ]; then
    mkdir -p $NVM_DIR
fi

# Install nvm if not already installed
if [ ! -s "$NVM_DIR/nvm.sh" ]; then
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
fi

# Load nvm and install the required Node.js version
export NVM_DIR="$NVM_DIR"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install $NVM_VERSION
nvm use $NVM_VERSION

# Verify Node.js and npm versions
node -v
npm -v

# Install packages
npm install -g @unlighthouse/cli puppeteer

# Manually install missing dependencies
apt install -y chromium
apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget -y

.
.
.
#some code to download and execute the go binary

EDIT: I successfully install Chromium and missing dependencies on Jenkins pipeline.
Now the error changed to this:

Error: Unable to launch browser for worker, error message: Failed to launch the browser process! undefined
[4606:4606:0520/035905.234446:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

How do I add --no-sandbox for puppeteer launch from unlighthouse?

P.S:
I'm new to this Infra stuffs, I'm a iOS dev originally. Sorry if this is just me being stupid, but I'm really stumped.

Appreciate any help.

Thank you.

Reproduction

unlighthouse-ci --site --reporter jsonExpanded --urls / --output-path "./output"

System / Nuxt Info

System:
    OS: Linux 5.15 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Xeon(R) CPU @ 2.20GHz
    Memory: 3.54 GB / 7.77 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.20.2 - /usr/bin/node
    npm: 8.19.4 - /usr/bin/npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant