This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
cico_setup.sh
112 lines (90 loc) · 2.53 KB
/
cico_setup.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
#!/bin/bash
# Output command before executing
set -x
# Exit on error
set -e
# Source environment variables of the jenkins slave
# that might interest this worker.
function load_jenkins_vars() {
if [ -e "jenkins-env" ]; then
cat jenkins-env \
| grep -E "(DEVSHIFT_TAG_LEN|REGISTRY|REGISTRY_ORG|QUAY_USERNAME|QUAY_PASSWORD|JENKINS_URL|GIT_BRANCH|GIT_COMMIT|BUILD_NUMBER|ghprbSourceBranch|ghprbActualCommit|BUILD_URL|ghprbPullId)=" \
| sed 's/^/export /g' \
> ~/.jenkins-env
source ~/.jenkins-env
fi
}
function install_deps() {
# We need to disable selinux for now, XXX
/usr/sbin/setenforce 0 || :
# Get all the deps in
yum -y install \
docker \
make \
git \
curl
service docker start
echo 'CICO: Dependencies installed'
}
function cleanup_env {
EXIT_CODE=$?
echo "CICO: Cleanup environment: Tear down test environment"
make integration-test-env-tear-down
echo "CICO: Exiting with $EXIT_CODE"
}
function prepare() {
# Let's test
make docker-start
make docker-deps
make docker-generate
make docker-build
echo 'CICO: Preparation complete'
}
function run_tests_without_coverage() {
make docker-test
echo "CICO: ran tests without coverage"
}
function tag_push() {
local tag
local registry
tag=$1
docker tag build-tool-detector-deploy $tag
docker push $tag
}
function deploy() {
if [ -z "$REGISTRY" ]
then
echo "\$var is empty, assigning default"
REGISTRY="quay.io"
else
echo "\$Using custom registry $REGISTRY"
fi
if [ -z "$REGISTRY_ORG" ]
then
echo "\$var is empty, assigning default"
REGISTRY_ORG="openshiftio"
else
echo "\$Using custom registry $REGISTRY"
fi
if [ -n "${QUAY_USERNAME}" -a -n "${QUAY_PASSWORD}" ]; then
docker login -u ${QUAY_USERNAME} -p ${QUAY_PASSWORD} ${REGISTRY}
else
echo "Could not login, missing credentials for the registry"
fi
# Build build-tool-detector-depoy
make docker-image-deploy
TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN})
if [ "$TARGET" = "rhel" ]; then
tag_push ${REGISTRY}/${REGISTRY_ORG}/rhel-fabric8-services-build-tool-detector:$TAG
tag_push ${REGISTRY}/${REGISTRY_ORG}/rhel-fabric8-services-build-tool-detector:latest
else
tag_push ${REGISTRY}/${REGISTRY_ORG}/fabric8-services-build-tool-detector:$TAG
tag_push ${REGISTRY}/${REGISTRY_ORG}/fabric8-services-build-tool-detector:latest
fi
echo 'CICO: Image pushed, ready to update deployed app'
}
function cico_setup() {
load_jenkins_vars;
install_deps;
prepare;
}