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=========================================================
24 # Turn PROJECTS, BRANCHES and PROJECT_DIRECTORIES paramter strings into arrays
25 # Required in order to loop through them
26 PROJECTS=(`echo $PROJECTS | sed 's/,/\n/g'`)
27 BRANCHES=(`echo $BRANCHES | sed 's/,/\n/g'`)
28 PROJECT_DIRECTORIES=(`echo $PROJECT_DIRECTORIES | sed 's/,/\n/g'`)
29 # if commitids/project versions are given turn string into an array
30 PROJECT_VERSIONS=(`echo $PROJECT_VERSIONS | sed 's/,/\n/g'`) || echo "No project versions/commit ids specificed, latest sources will be used"
32 # Find and store array lenth of one of the arrays
33 ARRAY_LENGTH=$(echo ${#PROJECTS[@]})
34 # Take 1 of the array length for the loop
37 # Create project directories and clone source repositories into them
38 for i in $(seq 0 $ARRAY_LENGTH)
40 echo "----------------------------------------------------"
41 echo "Info: Creating project directory ${PROJECT_DIRECTORIES[$i]}"
42 echo "----------------------------------------------------"
43 mkdir -p $WORKSPACE/${PROJECT_DIRECTORIES[$i]}
45 echo "----------------------------------------------------"
46 echo "Info: Cloning ${PROJECTS[$i]} branch ${BRANCHES[$i]} into ${PROJECT_DIRECTORIES[$i]}"
47 echo "----------------------------------------------------"
48 git clone --single-branch --branch ${BRANCHES[$i]} $GIT_BASE_HTTPS${PROJECTS[$i]} $WORKSPACE/${PROJECT_DIRECTORIES[$i]}
50 if ((${#PROJECT_VERSIONS[@]})); then
51 echo "----------------------------------------------------"
52 echo "Info: Checking out ${PROJECTS[$i]} to commit ${PROJECT_VERSIONS[$i]}"
53 echo "----------------------------------------------------"
54 cd $WORKSPACE/${PROJECT_DIRECTORIES[$i]}
55 git checkout ${PROJECT_VERSIONS[$i]}