Easiest way to run Selenium tests in a Docker container over Jenkins CI

Viewed 6389

I want to execute my automated tests, written in Nightwatch-Cucumber over a Jenkins CI in a Docker container. I have a Docker image that I want to use for it.

This is what I want to do in more detail.

  1. Start tests over Jenkins CI job
  2. On the same machine the Docker image is loaded and the related Docker container will start. This container based on a Unix OS. Also, some configuration in Docker container will be executed.
  3. Tests will be executed (from local or remote) in a headless mode via xvfb and the report will be saved on Jenkins machine.

Over GitLab CI I've realized it over a .gitlab-ci.yml config file and it runs very good:

image: "my-docker-image"

stages:
  - "chrome-tests"

before_script:
  - "apt-get update"
  - "apt-get install -y wget bzip2"
  - "npm install"

cache:
  paths:
    - node_modules/
run-tests-on-chrome:
  stage: "chrome-tests"
  script:
    - "whereis xvfb-run"
    - "xvfb-run --server-args='-screen 0 1600x1200x24' npm run test-chrome"

But I want to realize the same procedure with Jenkins CI. What is the easiest way to do it and ro run my automated tests in a Docker image which is called by Jenkins? Should I write a Dockerfile or not or or or?

2 Answers
Related