I'm trying to set up a Gitlab CI/CD pipeline for our Dockerized Java app. The 
way this pipeline works is we have separate steps for building our Docker image 
and for running our unit tests. The unit test step is supposed to output an 
HTML test report which is uploaded as a job artifact, and also return an error 
if the tests fail so that the pipeline does not continue on to the deployment 
step.

The problem I'm having is I can't find a way to invoke Maven such that I get 
both an HTML report and a nonzero return code if the tests fail:

  *   If I invoke mvn 'surefire-report:report' or mvn 'surefire-report:report' 
'test' , then I get an HTML report, but the return code is 0 even if there are 
failed unit tests.
  *   If I invoke mvn 'test' 'surefire-report:report' , then, if there are 
failed tests, it exits with return code 1 - but it also exits without writing 
the HTML report. (If there are no failed tests, then it does write the report, 
but a report that's only generated when nothing fails is of limited use.)
  *   My current workaround is mvn 'surefire-report:report' && mvn 'test' , 
which works, but also runs the tests twice.

Disclaimer

The information contained in this communication from the sender is 
confidential. It is intended solely for use by the recipient and others 
authorized to receive it. If you are not the recipient, you are hereby notified 
that any disclosure, copying, distribution or taking action in relation of the 
contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been 
automatically archived by Mimecast Ltd, an innovator in Software as a Service 
(SaaS) for business. Providing a safer and more useful place for your human 
generated data. Specializing in; Security, archiving and compliance. To find 
out more visit the Mimecast website.

Reply via email to