forked from fabric8-services/fabric8-toggles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cico_build_deploy.sh
58 lines (45 loc) · 1.34 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
#!/bin/bash
# Output command before executing
set -x
# Exit on error
set -e
REGISTRY="push.registry.devshift.net"
function tag_push() {
TARGET=$1
docker tag f8toggles-deploy $TARGET
docker push $TARGET
}
# 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|DEVSHIFT_USERNAME|DEVSHIFT_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 login() {
if [ -n "${DEVSHIFT_USERNAME}" -a -n "${DEVSHIFT_PASSWORD}" ]; then
docker login -u ${DEVSHIFT_USERNAME} -p ${DEVSHIFT_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
# Get all the deps in
yum -y install \
docker \
make \
git \
curl
service docker start
load_jenkins_vars
TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN})
docker build -t f8toggles-deploy -f Dockerfile .
login
tag_push ${REGISTRY}/fabric8-services/fabric8-toggles:$TAG
tag_push ${REGISTRY}/fabric8-services/fabric8-toggles:latest
echo 'CICO: Image pushed, ready to update deployed app'