Build, Test, Publish Results of NPM Build

Our CI involves 3 steps:

  • npm install/build
  • unit tests
  • publish unit tests (.xml file)
  • release artifact/image

Since we’ve moved to docker steps 2 and 3 are proving difficult since, if unit tests fail (return code != 0) the docker build process stops and we can’t publish the results. We would like the build to fail but the publish results stage to run anyway. Also, docker build seems only to output files from the last stage so we can’t just --output our test results as this is not the final step.

The only way I know how is to run two docker build commands - the first targeting the test stage and the second targeting the release stage.

Is there a better way?