Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven (MVN) return value on failure?

When we run mvn clean install from a batch (*.cmd) script, %ERRORLEVEL% is always 0 regardless if the build completes sucessfully or fails. How can you get Maven to return a non zero code for failures?

mvn clean install   
echo error:%ERRORLEVEL%

We're using Maven 2.


Update:

Note that if we do "mvn blah" then ERRORLEVEL=1 after the failure due to the bad target.

But if we do "mvn clean install" where the build fails due to a complication error we still get ERRORLEVEL=0.


Update 2:

Ok, this is because we are running Maven like:

mvn clean install | tee %LOGFILE%

I guess it's tee that is setting the ERRORLEVEL.

like image 427
Marcus Leon Avatar asked Aug 29 '12 16:08

Marcus Leon


1 Answers

Ok, this is because we are running Maven like:

mvn clean install | tee %LOGFILE%

I guess it's tee that is setting the ERRORLEVEL.

like image 168
Marcus Leon Avatar answered Oct 23 '22 01:10

Marcus Leon