This repository has been archived by the owner on Mar 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cico_build_deploy.sh
executable file
·74 lines (60 loc) · 1.7 KB
/
cico_build_deploy.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
#!/bin/bash
# Output command before executing
set -x
# Exit on error
set -e
REGISTRY=${REGISTRY:-quay.io}
# TARGET variable gives ability to switch context for building rhel based images, default is "centos"
# If CI slave is configured with TARGET="rhel" RHEL based images should be generated then.
TARGET=${TARGET:-"centos"}
if [ $TARGET == "rhel" ]; then
DOCKERFILE="Dockerfile.rhel"
else
DOCKERFILE="Dockerfile"
fi
NAMESPACE=${NAMESPACE:-"fabric8-services"}
# Source environment variables of the jenkins slave
# that might interest this worker.
function load_jenkins_vars() {
if [ -e "jenkins-env.json" ]; then
eval "$(./env-toolkit load -f jenkins-env.json \
DEVSHIFT_TAG_LEN \
QUAY_USERNAME \
QUAY_PASSWORD \
JENKINS_URL \
GIT_BRANCH \
GIT_COMMIT \
BUILD_NUMBER \
ghprbSourceBranch \
ghprbActualCommit \
BUILD_URL \
ghprbPullId)"
fi
}
function login() {
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
}
# We need to disable selinux for now, XXX
/usr/sbin/setenforce 0 || true
# Get all the deps in
yum -y install \
docker \
java-1.8.0-openjdk-devel \
make \
git \
curl \
go
go get github.com/openshift/source-to-image/cmd/s2i
export PATH=${PATH}:~/go/bin
load_jenkins_vars
TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN})
service docker start
login
export ADD_REST_ENDPOINTS=true
export S2I_BUILD=false
source ./buildAndPushToDocker.sh
echo 'CICO: Image pushed, ready to update deployed app'