ORANSC: Update java verify template
Change-Id: I1146180109525153b3ab04bdd85051b1a6e9593f
diff --git a/jjb/oransc/verify-jobs.sh b/jjb/oransc/verify-jobs.sh
index b9af93b..0e7dbdc 100755
--- a/jjb/oransc/verify-jobs.sh
+++ b/jjb/oransc/verify-jobs.sh
@@ -3,17 +3,72 @@
set -o nounset
set -o pipefail
-cd ${WORKSPACE}
+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 "----------------------------------------------------"
-${JAVA_HOME}/bin/java -version
+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
+$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
+
+# Set PATH to go executable
+export PATH=${PATH}:${GO_PATH}
+
echo "----------------------------------------------------"
echo "Proceeding with unit test"
echo "----------------------------------------------------"
-${MVN} clean install -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
\ No newline at end of file
+$MVN clean install -U -B $POMFILE -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn $LOCAL_MVN_PARAMS