Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing Maven task from shell script and getting error codes

Tags:

bash

shell

maven

I'm executing a Maven deploy task from a bash script however even if the Maven task fails the script will continue and complete without errors.

I have tried the -e flag but that causes the deploy to fail. I also tried the following (pseudo code)

result_code= mvn deploy
if [$result_code -gt 0];then
exit 1

Any suggestions how i can identify if the deploy was successful?

like image 905
cdugga Avatar asked Nov 14 '12 10:11

cdugga


People also ask

What does mvn clean command do?

mvn clean: Cleans the project and removes all files generated by the previous build.


1 Answers

result_code=mvn deploy is not the way to get return status

you can try e.g. :

#!/bin/bash
mvn deploy
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "Deployment Successful"
else
echo "Deployment Failed"
fi
like image 152
Kent Avatar answered Oct 05 '22 07:10

Kent