| #!/bin/bash |
| set -o errexit |
| set -o nounset |
| set -o pipefail |
| |
| cd $WORKSPACE |
| echo "Info: Update Java alternatives" |
| echo "----------------------------------------------------" |
| sudo /usr/bin/update-alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1 |
| sudo /usr/bin/update-alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1 |
| sudo /usr/bin/update-alternatives --install /usr/bin/javadoc javadoc "${JAVA_HOME}/bin/javadoc" 1 |
| sudo /usr/bin/update-alternatives --install /usr/bin/jconsole jconsole "${JAVA_HOME}/bin/jconsole" 1 |
| sudo /usr/bin/update-alternatives --install /usr/lib/jvm/java-openjdk java_sdk_openjdk "${JAVA_HOME}" 1 |
| sudo /usr/bin/update-alternatives --set java "${JAVA_HOME}/bin/java" |
| sudo /usr/bin/update-alternatives --set javac "${JAVA_HOME}/bin/javac" |
| sudo /usr/bin/update-alternatives --set javadoc "${JAVA_HOME}/bin/javadoc" |
| sudo /usr/bin/update-alternatives --set jconsole "${JAVA_HOME}/bin/jconsole" |
| sudo /usr/bin/update-alternatives --set java_sdk_openjdk "${JAVA_HOME}" |
| echo "Info: Java version" |
| echo "----------------------------------------------------" |
| echo -e "\tJava version: $(java -version 2>&1 | head -n 1)" |
| echo -e "\tJava compiler version: $(javac -version)" |
| echo -e "\tJAVA_HOME set to: ${JAVA_HOME}" |
| echo "----------------------------------------------------" |
| echo "Downloading Maven $MVN_VERSION from $MVN_URL" |
| wget -q $MVN_URL && unzip -qq apache-maven-${MVN_VERSION}-bin.zip |
| echo "Info: Maven version" |
| echo "----------------------------------------------------" |
| $MVN -version |
| echo "----------------------------------------------------" |
| echo "Downloading ONAP Maven XML for build process from oparent repo" |
| echo "----------------------------------------------------" |
| git clone "https://git.onap.org/oparent" $WORKSPACE/oparent |
| cd $WORKSPACE/oparent |
| # Check if a commitid parameter is given to specify a version of |
| # oparent repository to checkout. If commitid is not provided, the |
| # latest master version is used as default for backward |
| # compatibility for existing ONAP jobs. |
| set +o nounset |
| if [[ -v ${MVN_SETTINGS_XML_VERSION} ]]; then |
| git checkout "${MVN_SETTINGS_XML_VERSION}" |
| fi |
| set -o nounset |
| |
| # if MVN_PARAMS set then use them otherwise default to "" |
| LOCAL_MVN_PARAMS="" |
| set +o nounset |
| if [[ -n ${MVN_PARAMS} ]]; then |
| LOCAL_MVN_PARAMS=${MVN_PARAMS} |
| fi |
| set -o nounset |
| |
| # Copy Onap maven settings.xml to Jenkins home directory |
| if [ ! -d /home/jenkins/.m2 ]; then |
| mkdir -p /home/jenkins/.m2/ |
| fi |
| cp settings.xml /home/jenkins/.m2/settings.xml |
| cd $WORKSPACE |
| |
| POMFILE="-f $WORKSPACE/pom.xml" |
| set +o nounset |
| if [[ -n ${SUBDIRECTORY} ]]; then |
| POMFILE="-f $WORKSPACE/$SUBDIRECTORY/pom.xml" |
| echo "Setting pom.xml to use to $POMFILE" |
| fi |
| set -o nounset |
| |
| echo "----------------------------------------------------" |
| echo "Proceeding with unit test" |
| echo "----------------------------------------------------" |
| $MVN clean install -U -B $POMFILE -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn $LOCAL_MVN_PARAMS |