pass on Maven exit status as exit status of build script to let Hudson see that the build actually failed if Maven failed

This commit is contained in:
Axel Uhl committed 2014-01-29 06:18:53 +01:00
1 parent 36ffaea4d5
commit 68dabbc633
1 file changed
+21 -15
+21 -15
View File
@@ -37,7 +37,7 @@ fi
# if project_home is still empty we could not determine any suitable directory # if project_home is still empty we could not determine any suitable directory
if [[ $PROJECT_HOME == "" ]]; then if [[ $PROJECT_HOME == "" ]]; then
echo "Could neither determine nor get PROJECT_HOME. Please provide it by setting an environment variable with this name." echo "Could neither determine nor get PROJECT_HOME. Please provide it by setting an environment variable with this name."
exit exit 1
fi fi
if [ "$SERVERS_HOME" = "" ]; then if [ "$SERVERS_HOME" = "" ]; then
@@ -173,7 +173,7 @@ fi
if [[ "$@" == "release" ]]; then if [[ "$@" == "release" ]]; then
if [ ! -d $p2PluginRepository/plugins ]; then if [ ! -d $p2PluginRepository/plugins ]; then
echo "Could not find source directory $p2PluginRepository!" echo "Could not find source directory $p2PluginRepository!"
exit exit 1
fi fi
RELEASE_NOTES="" RELEASE_NOTES=""
@@ -189,7 +189,7 @@ if [[ "$@" == "release" ]]; then
if [[ $RELEASE_NOTES == "" ]]; then if [[ $RELEASE_NOTES == "" ]]; then
echo -e "\nCome on - I can not release without at least some notes about this release!" echo -e "\nCome on - I can not release without at least some notes about this release!"
exit exit 1
fi fi
echo -e "\nThank you! One last thing..." echo -e "\nThank you! One last thing..."
@@ -272,7 +272,7 @@ if [[ "$@" == "hot-deploy" ]]; then
if [ ! -d $p2PluginRepository/plugins ]; then if [ ! -d $p2PluginRepository/plugins ]; then
echo "Could not find source directory $p2PluginRepository!" echo "Could not find source directory $p2PluginRepository!"
exit exit 1
fi fi
if [[ $HAS_OVERWRITTEN_TARGET -eq 1 ]]; then if [[ $HAS_OVERWRITTEN_TARGET -eq 1 ]]; then
@@ -281,7 +281,7 @@ if [[ "$@" == "hot-deploy" ]]; then
if [ ! -d $SERVERS_HOME/$active_branch/plugins ]; then if [ ! -d $SERVERS_HOME/$active_branch/plugins ]; then
echo "Could not find target directory $SERVERS_HOME/$active_branch/plugins!" echo "Could not find target directory $SERVERS_HOME/$active_branch/plugins!"
exit exit 1
fi fi
# locate old bundle # locate old bundle
@@ -289,7 +289,7 @@ if [[ "$@" == "hot-deploy" ]]; then
OLD_BUNDLE=`find $SERVERS_HOME/$active_branch/plugins -maxdepth 1 -name "${OSGI_BUNDLE_NAME}_*.jar"` OLD_BUNDLE=`find $SERVERS_HOME/$active_branch/plugins -maxdepth 1 -name "${OSGI_BUNDLE_NAME}_*.jar"`
if [[ $OLD_BUNDLE == "" ]] || [[ $BUNDLE_COUNT -ne 1 ]]; then if [[ $OLD_BUNDLE == "" ]] || [[ $BUNDLE_COUNT -ne 1 ]]; then
echo "ERROR: Could not find any bundle named $OSGI_BUNDLE_NAME ($BUNDLE_COUNT). Perhaps your name is misspelled or you have no build?" echo "ERROR: Could not find any bundle named $OSGI_BUNDLE_NAME ($BUNDLE_COUNT). Perhaps your name is misspelled or you have no build?"
exit exit 1
fi fi
OLD_BUNDLE_BASENAME=`basename $OLD_BUNDLE .jar` OLD_BUNDLE_BASENAME=`basename $OLD_BUNDLE .jar`
@@ -313,7 +313,7 @@ if [[ "$@" == "hot-deploy" ]]; then
case $answer in case $answer in
"Y" | "y") echo "Continuing";; "Y" | "y") echo "Continuing";;
*) echo "Aborting..." *) echo "Aborting..."
exit;; exit 1;;
esac esac
fi fi
@@ -343,7 +343,7 @@ if [[ "$@" == "hot-deploy" ]]; then
echo "osgi> ss $OSGI_BUNDLE_NAME" echo "osgi> ss $OSGI_BUNDLE_NAME"
echo "71 INSTALLED $NEW_BUNDLE_BASENAME" echo "71 INSTALLED $NEW_BUNDLE_BASENAME"
echo "osgi> start 71" echo "osgi> start 71"
exit exit 1
fi fi
# first get bundle ID # first get bundle ID
@@ -360,7 +360,7 @@ if [[ "$@" == "hot-deploy" ]]; then
case $answer in case $answer in
"Y" | "y") echo "Continuing";; "Y" | "y") echo "Continuing";;
*) echo "Aborting..." *) echo "Aborting..."
exit;; exit 1;;
esac esac
fi fi
@@ -374,7 +374,7 @@ if [[ "$@" == "hot-deploy" ]]; then
echo "Uninstall procedure sucessful!" echo "Uninstall procedure sucessful!"
else else
echo "Something went wrong during uninstall. Please check error logs." echo "Something went wrong during uninstall. Please check error logs."
exit exit 1
fi fi
# now reinstall bundle # now reinstall bundle
@@ -388,11 +388,11 @@ if [[ "$@" == "hot-deploy" ]]; then
NEW_BUNDLE_STATUS=`echo ss | $NC_CMD | grep ${OSGI_BUNDLE_NAME}_ | grep ACTIVE` NEW_BUNDLE_STATUS=`echo ss | $NC_CMD | grep ${OSGI_BUNDLE_NAME}_ | grep ACTIVE`
if [[ $NEW_BUNDLE_STATUS == "" ]]; then if [[ $NEW_BUNDLE_STATUS == "" ]]; then
echo "ERROR: Something went wrong with start of bundle. Please check if everything went ok." echo "ERROR: Something went wrong with start of bundle. Please check if everything went ok."
exit exit 1
fi fi
echo "Everything seems to be ok. Bundle hot-deployed to server with new id $NEW_BUNDLE_ID" echo "Everything seems to be ok. Bundle hot-deployed to server with new id $NEW_BUNDLE_ID"
exit exit 0
fi fi
echo "Starting $@ of server..." echo "Starting $@ of server..."
@@ -454,7 +454,7 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
if [[ $ANDROID_HOME == "" ]]; then if [[ $ANDROID_HOME == "" ]]; then
echo "Environment variable ANDROID_HOME not found. Aborting." echo "Environment variable ANDROID_HOME not found. Aborting."
echo "Deactivate mobile build with parameter -a." echo "Deactivate mobile build with parameter -a."
exit exit 1
fi fi
echo "ANDROID_HOME=$ANDROID_HOME" echo "ANDROID_HOME=$ANDROID_HOME"
PATH=$PATH:$ANDROID_HOME/tools PATH=$PATH:$ANDROID_HOME/tools
@@ -481,6 +481,7 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
echo "Using following command: mvn $extra -DargLine=\"$APP_PARAMETERS\" -fae -s $MAVEN_SETTINGS $clean install" echo "Using following command: mvn $extra -DargLine=\"$APP_PARAMETERS\" -fae -s $MAVEN_SETTINGS $clean install"
echo "Maven version used: `mvn --version`" echo "Maven version used: `mvn --version`"
mvn $extra -DargLine="$APP_PARAMETERS" -fae -s $MAVEN_SETTINGS $clean install 2>&1 | tee $START_DIR/build.log mvn $extra -DargLine="$APP_PARAMETERS" -fae -s $MAVEN_SETTINGS $clean install 2>&1 | tee $START_DIR/build.log
MVN_EXIT_CODE=$?
if [ $reporting -eq 1 ]; then if [ $reporting -eq 1 ]; then
echo "INFO: Generating reports" echo "INFO: Generating reports"
@@ -500,7 +501,12 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
done done
fi fi
if [ $MVN_EXIT_CODE -eq 0 ]; then
echo "Build complete. Do not forget to install product..." echo "Build complete. Do not forget to install product..."
else
echo "Build had errors. Maven exit status was $MVN_EXIT_CODE"
fi
exit $MVN_EXIT_CODE
fi fi
if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then
@@ -510,13 +516,13 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then
case $answer in case $answer in
"Y" | "y") echo "Continuing";; "Y" | "y") echo "Continuing";;
*) echo "Aborting..." *) echo "Aborting..."
exit;; exit 1;;
esac esac
fi fi
if [ ! -d $ACDIR ]; then if [ ! -d $ACDIR ]; then
echo "Could not find directory $ACDIR - perhaps you are on a wrong branch?" echo "Could not find directory $ACDIR - perhaps you are on a wrong branch?"
exit exit 1
fi fi
# secure current state so that it can be reused if something goes wrong # secure current state so that it can be reused if something goes wrong