Today I experienced two new maven problem that took me some time to understand, both of which appeared when running the mvn release:preare goal. The first problem was a show-stopper in that it refused to run, giving me the following error:
Cannot run program "mvn" (in directory "/opt/hudson/.hudson/jobs/MySuperApp/workspace"): java.io.IOException: error=2, No such file or directory
It basically says that mvn cannot be found – even though I just started the problem. When I analyzed the stacktrace I found a clue to what was happening: «…
Maven makes a fork of its own process. I am not sure whether commands executed in this forked process go through the shell, but one thing was clear; it does not make use of any aliases you might have defined. And since the maven binary was not in my PATH, but simply defined as an alias to the executable in the maven directoy, the forked process could not execute it. The simple fix was to add the path containing the maven binary to the PATH (for instance in .bashrc). My path now looks like:
The other problem was revealed now that the goal was running. Even though I had specified -Dmaven.test.skip on the commandline, the tests still ran. Turns out you need to make a hack to get the arguments to pass through. Just pack all the arguments into -Darguments=’your arguments here’, e.g.