Herpandderp Herpandderp - 1 year ago 78
Java Question

Jenkins Maven release fails due to log files from unit tests

I unfortunately may have two questions in one, or rather the solution may go two different ways. I have log4j loggers set up in a few classes that I unit test on. When I run

mvn clean install
it obviously runs those tests and in turn creates a log file (that is usually empty as nothing exciting is being logged). This isn't necessarily a problem except that Jenkins doesn't seem to like this when I do
Perform Maven Release
. It yells about the workspace having local changes and it cites the log file before declaring failure.

I know its the unit tests because if I changed them to integration tests or ignore them, everything works fine. But I'd like a solution not a workaround.

Are there configurations in Jenkins that can allow me to remedy this?

Or is there a strategy for mocking or ignoring logging for Unit tests?

I don't necessarily want to ignore them, but it is interfering with creating a release.

Answer Source

I am not quite aware of what Perform Maven Release does, but I can suggest a couple of solutions:

  1. Remove the log file from your source code repository (as the log files gets regenerated on every run, I don't think it should reside in your source code repository).
  2. Add the path of the offending log file to a list of files that are ignored by version control (e.g. git uses a file called gitignore - https://git-scm.com/docs/gitignore)

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download