This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildLatest.sh
executable file
·122 lines (112 loc) · 3.54 KB
/
buildLatest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
#*****************************************************************
#*
#* Copyright 2020 IBM Corporation
#*
#* 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.
#*
#*****************************************************************
# Perform a build, install, and test of the latest commit in each repository
# function for converting repo name to image name
getImageName() {
dirName=$1
if [ $dirName == 'inventory' ]; then
imageName=kappnav-inv
else
imageName=kappnav-$dirName
fi
}
arg=$1
# make sure we're running in the build directory
if [ $(echo $PWD | awk '{ n=split($0,d,"/"); print d[n] }') != 'build' ]; then
echo 'Error: $kappnav/build dir must be current dir.'
echo ''
arg="--?"
fi
# print help if we need to
if [ x$arg == x'--?' ] || [ x$arg == x'-?' ]; then
echo ""
echo "Build the latest kAppNav, install it and run the tests. Note that the"
echo "repositories will be left in the master branch."
echo ""
echo ""
echo "syntax:"
echo ""
echo "buildLatest.sh"
echo ""
echo "This script uses the following environment variables."
echo " \$CLUSTER_URL - the URL to your OpenShift cluster"
echo " \$CLUSTER_USER - the user name for logging into your cluster; default is"
echo " is kubeadmin"
echo " \$CLUSTER_PWD - the password for logging into your cluster"
echo " \$CLUSTER_PLATFORM - the platform type of your cluster; default is ocp"
echo " \$DOCKER_ORG - the Docker org to publish to and pull from"
echo ""
echo " The script will prompt for values for any missing environments variables"
echo " that don't have a default"
exit 1
fi
# clean up our docker registry so we have enough space
# automatically answer 'y' to the prune prompt
echo "pruning Docker registry of dangling images"
echo "y\n" | docker image prune
# make sure all of the repositories are up to date
# then rebuild any images that are out of date
builtSomething="false"
. ./projectList.sh
for p in $BUILD_PROJECTS; do
echo ""
echo "***** build $p"
cd ../$p ; git checkout master; git pull
commit=$(git rev-parse HEAD)
getImageName $p
docker image inspect $imageName | grep $commit
if [ $? -eq 0 ]; then
echo "$imageName is already current."
else
echo "building $imageName"
./build.sh
builtSomething="true"
fi
cd -
done
# if nothing was built then there's nothing else to do
if [ $builtSomething == "false" ]; then
echo "All repositories are up to date. No need to install and test."
exit
fi
# publish images, install, and test
if [ x$CLUSTER_URL != x ]; then
url=$CLUSTER_URL
else
read -p "Enter your cluster url: " url
fi
if [ x$CLUSTER_USER != x ]; then
user=$CLUSTER_USER
else
user=kubeadmin
fi
if [ x$CLUSTER_PWD != x ]; then
pwd=$CLUSTER_PWD
else
read -p "Enter your cluster password: " url
fi
if [ x$CLUSTER_PLATFORM != x ]; then
platform=$CLUSTER_PLATFORM
else
platform=ocp
fi
if [ x$DOCKER_ORG != x ]; then
org=$DOCKER_ORG
else
read -p "Enter the Docker org to use: " org
fi
./setupKAppNavTestEnv.sh $url $user $pwd $platform $org -p