blob: 0e7dbdc33bafb0301502ad42237fb0100687eb03 [file] [log] [blame]
robert.tomczyk8d2bf802019-11-15 14:25:34 +00001#!/bin/bash
2set -o errexit
3set -o nounset
4set -o pipefail
5
robert.tomczykc9e75472021-12-01 18:55:33 +00006cd $WORKSPACE
7echo "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.tomczyk8d2bf802019-11-15 14:25:34 +000019echo "Info: Java version"
20echo "----------------------------------------------------"
robert.tomczykc9e75472021-12-01 18:55:33 +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.tomczyk8d2bf802019-11-15 14:25:34 +000024echo "----------------------------------------------------"
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 "----------------------------------------------------"
robert.tomczykc9e75472021-12-01 18:55:33 +000029$MVN -version
30echo "----------------------------------------------------"
31echo "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
44
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
53# 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
59
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
68# Set PATH to go executable
69export PATH=${PATH}:${GO_PATH}
70
robert.tomczyk8d2bf802019-11-15 14:25:34 +000071echo "----------------------------------------------------"
72echo "Proceeding with unit test"
73echo "----------------------------------------------------"
robert.tomczykc9e75472021-12-01 18:55:33 +000074$MVN clean install -U -B $POMFILE -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn $LOCAL_MVN_PARAMS