Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Setting up Ruby on Rails app to use Bitbucket Pipelines to run system tests

Hello!  I have a Ruby on Rails app that I'm using bitbucket pipelines to deploy to Heroku.  I have tests in the app that use minitest, capybara, selenium, and webdrivers.  For system tests, I have an application_system_test_case.rb file with this class that specifies the headless chrome browser and the system test files inherit from it:

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]

I've gotten the normal tests (model, controller, helper, etc) to successfully run in the pipeline, but if I try to run the system tests, I get errors related to the chrome browser not running properly.  I've tried various ideas, but haven't been able to get it to work.  Here is my bitbucket-pipelines.yml:

image: ruby:2.6.6
- step:
name: Deploy dev branch
deployment: test
- bundler
- yarn
# install nodejs & yarn
- apt-get update && apt-get install -y build-essential nodejs
- curl -sS | apt-key add -
- echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update
- apt-get install -y yarn
- yarn install
# install gems
- gem install rails
- bundle install --path vendor/bundle
# set up postgres
- export DATABASE_URL=postgresql://test_user:test_user_password@localhost/pipelines
- bundle exec rake db:create db:migrate --trace RAILS_ENV=test
- bundle exec rails test
- git push [to server]
- postgres
bundler: ./vendor
yarn: ./node_modules
image: postgres
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password

 Anyone know how to get this to work?

1 answer


I stumbled upon this post looking for an answer to this exact question.

I have spent the last two days trying and debugging various techniques to get this working for me, and I’m happy to say it finally works.

The issue with Chrome is that it crashes when run with a root user.

How I solved it was to use the following Dockerfile, push it to Docker and use it as the pipeline image

FROM ruby:3.1.3

# Set the TERM environment variable
ENV TERM=xterm

# Install dependencies
RUN apt-get update -qq && apt-get install -y \
postgresql \
postgresql-contrib \

# Install Chrome
RUN curl -sS -o - | apt-key add -
RUN echo "deb [arch=amd64] stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get install -y google-chrome-stable

# Install Yarn
RUN curl -sS | apt-key add - \
&& echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get install -y yarn

# Clean up
RUN apt-get autoremove -y && apt-get clean

# Set work directory in container
WORKDIR /myapp

# Copy the rest of the application into the work directory
COPY . /myapp

# Install Bundler
RUN gem install bundler -v 2.3.7
RUN bundle config set --global path "vendor/bundle"

# Change user
RUN useradd -ms /bin/bash appuser
RUN chown -R appuser:appuser /myapp /usr/local/bundle
USER appuser

This was useful to me because I was running many tests in parallel, so the Docker image saved me load times. 

You may be able to run "useradd" and "chown" and set the user as steps in your bitbucket-pipeline.yml, but I haven't tried that myself.

EDIT: You may also note the "# Install Chrome" section that may be necessary to make sure it's present in your build.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events