From 6eda973b81af3106adabc0edbae4f040d6fae5a2 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 23 Mar 2021 11:57:00 +0000 Subject: [PATCH] Add jenkins jobs for clamp-pilot repo Change-Id: I42a683a3705c48b087d2d7f538b4e5e070abd97a Signed-off-by: liamfallon --- jjb/local/global-templates-local-java.yaml | 65 +++++++++++++++++ .../clamp-pilot/policy-clamp-verify-jobs.yaml | 34 +++++++++ jjb/local/verify-jobs.sh | 71 +++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 jjb/local/global-templates-local-java.yaml create mode 100644 jjb/local/onap/clamp-pilot/policy-clamp-verify-jobs.yaml create mode 100755 jjb/local/verify-jobs.sh diff --git a/jjb/local/global-templates-local-java.yaml b/jjb/local/global-templates-local-java.yaml new file mode 100644 index 00000000..45715ec0 --- /dev/null +++ b/jjb/local/global-templates-local-java.yaml @@ -0,0 +1,65 @@ +--- +# This is a java verify template for local repositories +- job-template: + name: 'local-{project-name}-{stream}-verify-java' + disabled_job_var: false + node: onap-ubuntu1804 + + disabled: '{obj:disabled_job_var}' + concurrent: true + mvn_settings_xml_version: + mvn_params: + mvn_version: 3.5.4 + properties: + - logrotate + + parameters: + - project-parameters: + project: 'local/{project}' + branch: '{branch}' + - nordix-gerrit-parameters + - string: + name: JAVA_HOME + default: '/usr/lib/jvm/{jdk-version}-openjdk-amd64' + description: Java home + - string: + name: MVN_VERSION + default: '{mvn_version}' + description: Maven version + - string: + name: MVN_URL + default: https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/$MVN_VERSION/apache-maven-${{MVN_VERSION}}-bin.zip + description: URL to download Maven + - string: + name: MVN + default: $WORKSPACE/apache-maven-${{MVN_VERSION}}/bin/mvn + description: Path to mvn executable + - string: + name: MVN_SETTINGS_XML_VERSION + default: '{mvn_settings_xml_version}' + description: Commit ID of ONAP Oparent repository (https://git.onap.org/oparent/) to pull. Used for Maven settings file. Can be left blank to pull the latest version. + - string: + name: MVN_PARAMS + default: '{mvn_params}' + description: Maven build parameters + scm: + - git-scm-gerrit: + ssh-credentials-id: nordixinfra-nordix-gerrit-ssh + branch: '{branch}' + refspec: $GERRIT_REFSPEC + wipe_workspace: true + clean_before: false + + triggers: + - nordix-gerrit-trigger-patchset-created: + project: 'local/{project}' + branch: '{branch}' + files: '**' + + wrappers: + - build-timeout: + timeout: 45 + + builders: + - shell: + !include-raw-escape: ./verify-jobs.sh diff --git a/jjb/local/onap/clamp-pilot/policy-clamp-verify-jobs.yaml b/jjb/local/onap/clamp-pilot/policy-clamp-verify-jobs.yaml new file mode 100644 index 00000000..eae68703 --- /dev/null +++ b/jjb/local/onap/clamp-pilot/policy-clamp-verify-jobs.yaml @@ -0,0 +1,34 @@ +--- +# +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# this job gets triggered when a change is proposed to +# policy/clamp project on Nordix Gerrit. + +- project: + name: onap-clamp-pilot-verify + project: onap/clamp-pilot + project-name: onap-clamp-pilot + + stream: + - 'master': + branch: '{stream}' + jdk-version: java-11 + jobs: + - 'onap-{project-name}-{stream}-verify-java' diff --git a/jjb/local/verify-jobs.sh b/jjb/local/verify-jobs.sh new file mode 100755 index 00000000..7a850b04 --- /dev/null +++ b/jjb/local/verify-jobs.sh @@ -0,0 +1,71 @@ +#!/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 -- 2.25.1