forked from openshiftio/openshift.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cico_build_deploy.sh
68 lines (56 loc) · 1.74 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
#!/bin/bash
# Show command before executing
set -x
# Exit on error
set -e
# Export needed vars
for var in BUILD_NUMBER BUILD_URL; do
export $(grep ${var} jenkins-env | xargs)
done
export BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M:%S`+00:00
# We need to disable selinux for now, XXX
/usr/sbin/setenforce 0
# Get all the deps in
yum -y install docker
yum clean all
service docker start
# Build builder image
docker build -t wwwopenshiftio-builder -f Dockerfile.builder .
mkdir -p dist && docker run --detach=true --name=wwwopenshiftio-builder -t -v $(pwd)/dist:/dist:Z -e BUILD_NUMBER -e BUILD_URL -e BUILD_TIMESTAMP wwwopenshiftio-builder
# Build almigty-ui
docker exec wwwopenshiftio-builder npm install
## Exec unit tests
#docker exec wwwopenshiftio-builder ./run_unit_tests.sh
#if [ $? -eq 0 ]; then
# echo 'CICO: unit tests OK'
#else
# echo 'CICO: unit tests FAIL'
# exit 1
#fi
## Exec functional tests
#docker exec wwwopenshiftio-builder ./run_functional_tests.sh
#if [ $? -eq 0 ]; then
# echo 'CICO: functional tests OK'
docker exec wwwopenshiftio-builder npm run build:prod
docker exec -u root wwwopenshiftio-builder cp -r /home/fabric8/wwwopenshiftio/dist /
## All ok, deploy
# if [ $? -eq 0 ]; then
# echo 'CICO: build OK'
docker build -t wwwopenshiftio-deploy -f Dockerfile.deploy . && \
docker tag wwwopenshiftio-deploy 8.43.84.245.xip.io/fabric8io/wwwopenshiftio:latest && \
docker push 8.43.84.245.xip.io/fabric8io/wwwopenshiftio:latest
if [ $? -eq 0 ]; then
echo 'CICO: image pushed, ready to update deployed app'
exit 0
else
echo 'CICO: Image push to registry failed'
exit 2
fi
# else
# echo 'CICO: app tests Failed'
# exit 1
# fi
#else
# echo 'CICO: functional tests FAIL'
# exit 1
#fi