blob: 7a850b04efa456849770b192bd578dc6817af927 [file] [log] [blame]
robert.tomczyk08e50eb2020-08-11 16:53:28 +01001#!/bin/bash
2set -o errexit
3set -o nounset
4set -o pipefail
5
6cd $WORKSPACE
robert.tomczykda550f92020-11-24 13:39:16 +00007echo "Info: Update Java alternatives"
8echo "----------------------------------------------------"
9sudo /usr/bin/update-alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1
10sudo /usr/bin/update-alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1
11sudo /usr/bin/update-alternatives --install /usr/bin/javadoc javadoc "${JAVA_HOME}/bin/javadoc" 1
12sudo /usr/bin/update-alternatives --install /usr/bin/jconsole jconsole "${JAVA_HOME}/bin/jconsole" 1
13sudo /usr/bin/update-alternatives --install /usr/lib/jvm/java-openjdk java_sdk_openjdk "${JAVA_HOME}" 1
14sudo /usr/bin/update-alternatives --set java "${JAVA_HOME}/bin/java"
15sudo /usr/bin/update-alternatives --set javac "${JAVA_HOME}/bin/javac"
16sudo /usr/bin/update-alternatives --set javadoc "${JAVA_HOME}/bin/javadoc"
17sudo /usr/bin/update-alternatives --set jconsole "${JAVA_HOME}/bin/jconsole"
18sudo /usr/bin/update-alternatives --set java_sdk_openjdk "${JAVA_HOME}"
robert.tomczyk08e50eb2020-08-11 16:53:28 +010019echo "Info: Java version"
20echo "----------------------------------------------------"
robert.tomczykda550f92020-11-24 13:39:16 +000021echo -e "\tJava version: $(java -version 2>&1 | head -n 1)"
22echo -e "\tJava compiler version: $(javac -version)"
23echo -e "\tJAVA_HOME set to: ${JAVA_HOME}"
robert.tomczyk08e50eb2020-08-11 16:53:28 +010024echo "----------------------------------------------------"
25echo "Downloading Maven $MVN_VERSION from $MVN_URL"
26wget -q $MVN_URL && unzip -qq apache-maven-${MVN_VERSION}-bin.zip
27echo "Info: Maven version"
28echo "----------------------------------------------------"
29$MVN -version
30echo "----------------------------------------------------"
robert.tomczyk750a20f2020-08-18 11:08:43 +010031echo "Downloading ONAP Maven XML for build process from oparent repo"
32echo "----------------------------------------------------"
33git clone "https://git.onap.org/oparent" $WORKSPACE/oparent
34cd $WORKSPACE/oparent
35# Check if a commitid parameter is given to specify a version of
36# oparent repository to checkout. If commitid is not provided, the
37# latest master version is used as default for backward
38# compatibility for existing ONAP jobs.
39set +o nounset
40if [[ -v ${MVN_SETTINGS_XML_VERSION} ]]; then
41 git checkout "${MVN_SETTINGS_XML_VERSION}"
42fi
43set -o nounset
afenner29099642020-08-28 16:09:31 +010044
45# if MVN_PARAMS set then use them otherwise default to ""
46LOCAL_MVN_PARAMS=""
47set +o nounset
48if [[ -n ${MVN_PARAMS} ]]; then
49 LOCAL_MVN_PARAMS=${MVN_PARAMS}
50fi
51set -o nounset
52
robert.tomczyk750a20f2020-08-18 11:08:43 +010053# Copy Onap maven settings.xml to Jenkins home directory
54if [ ! -d /home/jenkins/.m2 ]; then
55 mkdir -p /home/jenkins/.m2/
56fi
57cp settings.xml /home/jenkins/.m2/settings.xml
58cd $WORKSPACE
afennera6c9eaa2020-10-21 17:04:50 +010059
60POMFILE="-f $WORKSPACE/pom.xml"
61set +o nounset
62if [[ -n ${SUBDIRECTORY} ]]; then
63 POMFILE="-f $WORKSPACE/$SUBDIRECTORY/pom.xml"
64 echo "Setting pom.xml to use to $POMFILE"
65fi
66set -o nounset
67
robert.tomczyk750a20f2020-08-18 11:08:43 +010068echo "----------------------------------------------------"
robert.tomczyk08e50eb2020-08-11 16:53:28 +010069echo "Proceeding with unit test"
70echo "----------------------------------------------------"
afennera6c9eaa2020-10-21 17:04:50 +010071$MVN clean install -U -B $POMFILE -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn $LOCAL_MVN_PARAMS