taguenizy
taguenizy

Reputation: 2265

How to bind Jenkins build output with tests result?

I'm setting automated protractor tests to run in a docker container with the help of jenkins. But not been able to make a the jenkins build result to reflect the testing outcome (if some test fail, build should fail also).

Important to say that all tests should run, even if the first one fails.

The tests are initiated with docker-compose up --abort-on-container-exit and my docker-compose file looks like:

version: '2'

services:
  selenium:
    image: selenium/standalone-chrome
    ports:
      - 4444:4444
    volumes:
      - /dev/shm:/dev/shm
  protractor:
    volumes:
      - ./reporting:/assets/reporting
    image: protractor-test
    command: "dockerize -wait http://selenium:4444 -timeout 60m protractor /assets/conf.js"

Upvotes: 2

Views: 370

Answers (1)

Rogério Peixoto
Rogério Peixoto

Reputation: 2247

Looks like your docker-compose command is returning exit code 0 no matter what.

How about using a Jasmine xunit reporter to generate a test report, copy the generated xml test report to outside the container (using docker cp), and then publish it using Jenkins' post-build action?

The job will be marked as failed if the xml is not present, which means there's an error during the test runtime or it will be marked as unstable, if it has failed any of the test asserts.

Upvotes: 1

Related Questions