monasca-thresh/run_maven.sh
Craig Bryant 698b9a5d2d Ensure the same branch is used for common build
Only the master branch is used today, but be ready when there
are additional branches

Almost got it right on the last commit. Didn't actually use the
new variable. Unfortunately, to test these changes, we have to
actually get to the post jobs.

Change-Id: I54b5d484ea1da976abfa1e6cfc780abe21827030
2016-02-09 07:36:12 -07:00

60 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -x
env
# Download maven 3 if the system maven isn't maven 3
VERSION=`mvn -v | grep "Apache Maven 3"`
if [ -z "${VERSION}" ]; then
curl http://archive.apache.org/dist/maven/binaries/apache-maven-3.2.1-bin.tar.gz > apache-maven-3.2.1-bin.tar.gz
tar -xvzf apache-maven-3.2.1-bin.tar.gz
MVN=${PWD}/apache-maven-3.2.1/bin/mvn
else
MVN=mvn
fi
# Get the expected common version
COMMON_VERSION=$1
# Get rid of the version argument
shift
# Get rid of the java property name containing the args
shift
RUN_BUILD=false
for ARG in $*; do
if [ "$ARG" = "package" ]; then
RUN_BUILD=true
fi
if [ "$ARG" = "install" ]; then
RUN_BUILD=true
fi
done
if [ $RUN_BUILD = "true" ]; then
if [ ! -z "$ZUUL_BRANCH" ]; then
BRANCH=${ZUUL_BRANCH}
else
BRANCH=${ZUUL_REF}
fi
( cd common; ./build_common.sh ${MVN} ${COMMON_VERSION} ${BRANCH} )
RC=$?
if [ $RC != 0 ]; then
exit $RC
fi
fi
# Invoke the maven 3 on the real pom.xml
( cd thresh; ${MVN} -DgitRevision=`git rev-list HEAD --max-count 1 --abbrev=0 --abbrev-commit` $* )
RC=$?
# Copy the jars where the publisher will find them
if [ $RUN_BUILD = "true" ]; then
if [ ! -L target ]; then
ln -sf thresh/target target
fi
fi
rm -fr apache-maven-3.2.1*
exit $RC