#!/bin/bash

#
# Wrapper around jenkins_generic_job that will allow output
# from that script to always be printed to the screen and
# recoverable if Jenkins is forced to kill the job. This is the
# script that should be used from Jenkins.
#

SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd )
DATE_STAMP=$(date "+%Y-%m-%d_%H%M%S")
export JENKINS_START_TIME=$(date "+%s")

$SCRIPT_DIR/jenkins_generic_job "$@" >& JENKINS_$DATE_STAMP

cd $SCRIPT_DIR

for SUB in $(git submodule status | awk '{print $2}'); do
    git submodule deinit ${SUB}
done

git config --remove-section submodule.mpas-o
git config --remove-section submodule.mpas-cice
git config --remove-section submodule.mpas-li
