2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2020 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
26 echo "----------------------------------------------------"
27 echo "Info: Java version"
28 echo "----------------------------------------------------"
31 echo "----------------------------------------------------"
32 echo "Info: Downloading Maven $MVN_VERSION from $MVN_URL"
33 echo "----------------------------------------------------"
34 wget -q $MVN_URL && unzip -qqn apache-maven-$MVN_VERSION-bin.zip
36 echo "----------------------------------------------------"
37 echo "Info: Maven version"
38 echo "----------------------------------------------------"
41 echo "----------------------------------------------------"
42 echo "Info: Downloading ONAP Maven XML for build process"
43 echo "----------------------------------------------------"
44 git clone "https://git.onap.org/oparent" $WORKSPACE/oparent
46 # Check if a commitid parameter is given to specify a version of
47 # oparent repository to checkout
48 if [[ -v MVN_SETTINGS_XML_VERSION ]]; then
49 git checkout $MVN_SETTINGS_XML_VERSION
51 # Copy Onap maven settings.xml to Jenkins home directory
52 mkdir -p /home/jenkins/.m2/
53 cp settings.xml /home/jenkins/.m2/settings.xml
57 echo "----------------------------------------------------"
58 echo "Info: Ensuring Docker is running"
59 echo "----------------------------------------------------"
60 # If docker daemon isnt up attempt to start it
63 systemctl start docker
66 # Turn PROJECTS and PROJECT_DIRECTORIES paramter strings into arrays
67 # Required in order to loop through them
68 PROJECTS=(`echo $PROJECTS | sed 's/,/\n/g'`)
69 PROJECT_DIRECTORIES=(`echo $PROJECT_DIRECTORIES | sed 's/,/\n/g'`)
71 # Find and store array lenth of one of the arrays
72 ARRAY_LENGTH=$(echo ${#PROJECTS[@]})
73 # Take 1 of the array length for the loop
76 # For each project source repository do a maven build
77 # e.g. maven clean install -DskipTests -Pdocker
78 for i in $(seq 0 $ARRAY_LENGTH)
80 echo "----------------------------------------------------"
81 echo "INFO: Maven Build for ${PROJECTS[$i]}"
82 echo "----------------------------------------------------"
83 $MVN -U clean install $MVN_PARAMS -f ${PROJECT_DIRECTORIES[$i]}