Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to configure the CHROME_BIN in pipeline Edited

4 answers

1 vote
Graham Gatus Atlassian Team Mar 06, 2019

@kumarpr I've put together an example repository demonstrating Puppeteer with Chromium in pipelines - https://bitbucket.org/bitbucketpipelines/example-chromium-headless-puppeteer/src/master/. In your case, it looks like there were additional dependencies that need edto be installed into the node:8.9.4 image in order to have Puppeteer be able to launch a Chromium browser instance.

In the linked example, the bitbucket-pipelines.yml file installs these required dependencies, then uses Puppeteer to start a Chromium instance and take a screenshot, saving it as a build artifact.

Hi Graham,

Thanks for your help. It's working fine now.

Thanks a lots.

Trying to use the example script in your repository does not work for me. 

I get: 

 

E: Unable to locate package libgconf-2-4

E: Unable to locate package update

0 votes
Graham Gatus Atlassian Team Mar 05, 2019

@kumarpr , are you able to provide your bitbucket-pipelines.yml file?

Based on the error, it sounds like you may need to install chromium browser first.

You can test this by running `which chromium-browser` in your pipeline, which should give the location of chromium.

If chromium is not present, for an Ubuntu based build image (e.g when using the default pipelines image), you can install this via:

```

apt-get update && apt-get install -y chromium-browser

```

Hi Graham,

Thanks for your reply.

bitbucket-pipelines.yml

image: node:8.9.4
options:
max-time: 20
pipelines:
default:
- step:
name: Build and test
caches:
- node
script:
- npm install
- npm run lint
- npm run test
- npm run build

I have treid to install the puppeteer as well to use the ChromeHeadless

image: node:8.9.4
options:
max-time: 20
pipelines:
default:
- step:
name: Build and test
caches:
- node
script:
- npm install
- npm install -D puppeteer
- npm run lint
- npm run test
- npm run build 

Hi,

 

I also have the same issue.

Currently I made a new Angular application and try to setup the default pipeline.

 

karma.conf.js

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/frontenddevnet'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});

 

bitbucket-pipelines.yml

image: node

pipelines:
default:
- step:
name: Lint and Test
caches:
- node
script:
- npm install
- npm run lint
- npm run test

error
21 08 2019 10:58:42.349:WARN [karma]: No captured browser, open http://localhost:9876/
21 08 2019 10:58:42.399:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9876/
21 08 2019 10:58:42.399:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
21 08 2019 10:58:42.408:INFO [launcher]: Starting browser Chrome
21 08 2019 10:58:42.409:ERROR [launcher]: No binary for Chrome browser on your platform.
Please, set "CHROME_BIN" env variable.
21 08 2019 10:58:47.381:WARN [karma]: No captured browser, open http://localhost:9876/

 

how to configure the Chrome browser? Any ideas?

 

Kind regards,

Phil

0 votes

Hey @kumarpr  I just ended up here as I was having the same problem.

Using @Graham Gatus  pipeline as inspiration and after some research I discovered that puppeteer node package installs a bundled chromium binary, so installing chromium again seems a bit redundant.

Instead, try to:

  1. Install some OS package dependencies (libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2)
  2. Include `puppeteer` as a dev dependency on your `package.json` file
  3. Let npm know where this chrome bundled version is through the`CHROME_BIN` environment variable

Here's how my solution looks like:

```

image: node:10.16.3

pipelines:
  default:
    - step:
      name: Install dependencies and test the app
      caches:
        - node
      script:
        - apt update && apt install -yq libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2
        - npm ci
        - export CHROME_BIN="./node_modules/puppeteer/.local-chromium/linux-884014/chrome-linux/chrome"
        - npm run testci


```

Where testci is the following custom command:

```

node node_modules/@angular/cli/bin/ng test --no-progress --no-watch --reporters junit --browsers ChromeHeadlessCI

```

PS: @PhilippHabele  see if this solves your issue too :)

Hope this help someone!

Cheers!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,942 views 68 21
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you