forked from fabric8-services/fabric8-jenkins-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cico_build_deploy.sh
67 lines (57 loc) · 2.12 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
#
# Build script for CI builds on CentOS CI https://ci.centos.org/view/Devtools/job/devtools-fabric8-jenkins-proxy-build-master/
set -e
###################################################################################
# Installs all requires build tools to compile, test and build the container image
# Arguments:
# None
# Returns:
# None
###################################################################################
function setup_build_environment() {
[ -f jenkins-env ] && cat jenkins-env | grep -e GIT -e DEVSHIFT -e JOB_NAME > inherit-env
[ -f inherit-env ] && . inherit-env
# We need to disable selinux for now, XXX
/usr/sbin/setenforce 0
yum -y install docker make golang git
service docker start
echo 'CICO: Build environment created.'
}
###################################################################################
# Setup the environment for Go, aka the GOPATH
# Arguments:
# None
# Returns:
# None
###################################################################################
function setup_golang() {
# Show Go version
go version
# Setup GOPATH
mkdir $HOME/go $HOME/go/src $HOME/go/bin $HOME/go/pkg
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
}
###################################################################################
# Make sure the Go sources are at their proper location within GOPATH.
# See https://golang.org/doc/code.html
# Arguments:
# None
# Returns:
# None
###################################################################################
function setup_workspace() {
mkdir -p $GOPATH/src/github.com/fabric8-services
cp -r $HOME/payload $GOPATH/src/github.com/fabric8-services/fabric8-jenkins-proxy
}
setup_build_environment
setup_golang
setup_workspace
cd $GOPATH/src/github.com/fabric8-services/fabric8-jenkins-proxy
echo "HEAD of repository `git rev-parse --short HEAD`"
make all
if [[ "$JOB_NAME" = "devtools-fabric8-jenkins-proxy-build-master" ]]; then
TAG=$(echo ${GIT_COMMIT} | cut -c1-${DEVSHIFT_TAG_LEN})
make push REGISTRY_USER=${DEVSHIFT_USERNAME} REGISTRY_PASSWORD=${DEVSHIFT_PASSWORD} IMAGE_TAG=${TAG}
fi