| #!/bin/bash |
| # ============LICENSE_START======================================================= |
| # Copyright (C) 2020 The Nordix Foundation. All rights reserved. |
| # ================================================================================ |
| # 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========================================================= |
| |
| set -o errexit |
| set -o nounset |
| set -o pipefail |
| |
| cd $WORKSPACE |
| |
| echo "----------------------------------------------------" |
| echo "Info: Java version" |
| echo "----------------------------------------------------" |
| java -version |
| |
| echo "----------------------------------------------------" |
| echo "Info: Downloading Maven $MVN_VERSION from $MVN_URL" |
| echo "----------------------------------------------------" |
| wget -q $MVN_URL && unzip -qqn apache-maven-$MVN_VERSION-bin.zip |
| |
| echo "----------------------------------------------------" |
| echo "Info: Maven version" |
| echo "----------------------------------------------------" |
| $MVN -version |
| |
| echo "----------------------------------------------------" |
| echo "Info: Downloading ONAP Maven XML for build process" |
| 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 [[ -v MVN_SETTINGS_XML_VERSION ]]; then |
| git checkout $MVN_SETTINGS_XML_VERSION |
| fi |
| # Copy Onap maven settings.xml to Jenkins home directory |
| mkdir -p /home/jenkins/.m2/ |
| cp settings.xml /home/jenkins/.m2/settings.xml |
| cd $WORKSPACE |
| |
| |
| echo "----------------------------------------------------" |
| echo "Info: Ensuring Docker is running" |
| echo "----------------------------------------------------" |
| # If docker daemon isnt up attempt to start it |
| if ! docker info; |
| then |
| systemctl start docker |
| fi |
| |
| # Turn PROJECTS and PROJECT_DIRECTORIES paramter strings into arrays |
| # Required in order to loop through them |
| PROJECTS=(`echo $PROJECTS | sed 's/,/\n/g'`) |
| PROJECT_DIRECTORIES=(`echo $PROJECT_DIRECTORIES | sed 's/,/\n/g'`) |
| |
| # Find and store array lenth of one of the arrays |
| ARRAY_LENGTH=$(echo ${#PROJECTS[@]}) |
| # Take 1 of the array length for the loop |
| ((ARRAY_LENGTH--)) |
| |
| # For each project source repository do a maven build |
| # e.g. maven clean install -DskipTests -Pdocker |
| for i in $(seq 0 $ARRAY_LENGTH) |
| do |
| echo "----------------------------------------------------" |
| echo "INFO: Maven Build for ${PROJECTS[$i]}" |
| echo "----------------------------------------------------" |
| $MVN -U clean install $MVN_PARAMS -f ${PROJECT_DIRECTORIES[$i]} |
| done |