How to Mark a Jenkins Job Red When Tests Fail In A Maven Build
The default setting in Jenkins is to mark a job yellow, when a Maven build fails because of failing tests. If you don't want to have three status of your jobs, you can configure Jenkins so, that the jobs also mark red independent why a Maven build fails. For this you will need administration rights on your Jenkins instance. Following steps have to be done:
- Go to
Manage Jenkins -> Manage system.
Maven Project Configuration -> Global Maven_OPTS.
- Save this change and that's it.
Your next job run will consider this configuration. Unfortunately, this configuration has only effects for Maven jobs. Freestyle jobs ignore this configuration (see also this bug). But a workaround exists:
- Install the TextFinder plugin via
Manage Jenkins -> Manage Plugin.
- Open the Freestyle job's configuration that should be marked red, when Maven tests fail.
- Click on
Add a post-build action(in section
Post-build Action) and select
Jenkins Text Finder.
- Activate the check box
Also search the console output.
- Add the value
There are test failuresto
- Save this change.