Chrome Binary Missing in Jenkins Build
I’m having trouble with my CI pipeline after updating to Node 18. My Vue project works perfectly when I run tests locally, but Jenkins keeps failing with a Chrome binary error.
The Error I’m Getting
When Jenkins tries to run the test suite, it throws this error:
Cannot start ChromeHeadless
Can not find the binary /home/jenkins/.cache/puppeteer/chrome/linux-134.0.6998.35/chrome-linux64/chrome
Please set env variable CHROME_BIN
My Current Setup
Here’s my karma configuration file:
process.env.CHROME_BIN = require('puppeteer').executablePath()
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-coverage')
],
browsers: ['HeadlessChrome'],
customLaunchers: {
HeadlessChrome: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
'--disable-web-security',
'--disable-gpu'
]
}
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
singleRun: true
});
};
I’ve tried updating puppeteer to the latest version and setting the CHROME_BIN environment variable manually, but nothing seems to work. The same configuration works fine on other projects using the old Jenkins setup.
Has anyone encountered this issue before? Any suggestions on how to fix the Chrome binary path problem in Jenkins?