-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·53 lines (41 loc) · 1.36 KB
/
build.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
#!/bin/bash
set -euo pipefail
SA=~/.gke_sa.json
HELM_VERSION=2.10.0
function install_dependencies() {
wget https://github.com/jenkins-x/jx/releases/download/v${JX_VERSION}/jx-linux-amd64.tar.gz
tar xvf jx-linux-amd64.tar.gz
rm jx-linux-amd64.tar.gz
mkdir -p ~/.jx/bin
wget https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz
tar xvf helm-v${HELM_VERSION}-linux-amd64.tar.gz
rm helm-v${HELM_VERSION}-linux-amd64.tar.gz
mv linux-amd64/helm ~/.jx/bin
rm -fr linux-amd64
~/.jx/bin/helm init --client-only
}
function configure_environment() {
echo ${GKE_SA_JSON} > ${SA}
git config --global --add user.name "${GIT_USER}"
git config --global --add user.email "${GIT_EMAIL}"
}
function apply() {
OLDIFS=$IFS
CLUSTER_COMMAND=""
IFS=$','
for ENVIRONMENT in $ENVIRONMENTS; do
CLUSTER_COMMAND="${CLUSTER_COMMAND} -c ${ENVIRONMENT}"
done
IFS=$OLDIFS
git status
if [[ "${CI_BRANCH}" == "master" ]]; then
echo "Running master build"
./jx create terraform --verbose ${CLUSTER_COMMAND} -b --install-dependencies -o ${ORG} --gke-service-account ${SA}
else
echo "Running PR build for ${CI_BRANCH}"
./jx create terraform --verbose ${CLUSTER_COMMAND} -b --install-dependencies -o ${ORG} --gke-service-account ${SA} --skip-terraform-apply --local-organisation-repository .
fi
}
install_dependencies
configure_environment
apply