-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-build.sh
executable file
·76 lines (54 loc) · 1.53 KB
/
jenkins-build.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
#!/bin/bash
set -x
# Private project dependencies
private_deps=( )
support_deps=( "launchpad.net/gocheck" "github.com/scottferg/go2xunit" )
BINARYNAME=vip
ROOTDIR=$(pwd)
LOCAL_GOPATH=$ROOTDIR/gopath
GOROOT=$HOME/go
rm -rf $LOCAL_GOPATH
export GOPATH=$LOCAL_GOPATH
export PATH=$GOROOT/bin:$LOCAL_GOPATH/bin:$GOPATH/bin:/usr/local/bin:$PATH
IMPORTROOT=github.com/vokalinteractive
IMPORTPATH=$IMPORTROOT/$BINARYNAME
mkdir -p $LOCAL_GOPATH/src/$IMPORTPATH
rm -rf $LOCAL_GOPATH/src/$IMPORTPATH
mkdir -p $LOCAL_GOPATH/src/$IMPORTPATH
cp *.go $LOCAL_GOPATH/src/$IMPORTPATH
for dir in */
do
if [ $dir != "gopath/" ]; then
mkdir -p $LOCAL_GOPATH/src/$IMPORTPATH
cp -r $dir $LOCAL_GOPATH/src/$IMPORTPATH
fi
done
# Clone necessary dependencies
for dep in "${private_deps[@]}"
do
rm -rf $LOCAL_GOPATH/src/$IMPORTROOT/$dep
git clone [email protected]:vokalinteractive/$dep.git $LOCAL_GOPATH/src/$IMPORTROOT/$dep
done
# Build any ancillary tools/libraries
for dep in "${support_deps[@]}"
do
go get $dep
go install $dep
done
TESTFILE=$ROOTDIR/tests.xml
COVERAGEOUT=$ROOTDIR/coverage.out
COVERAGEHTML=$ROOTDIR/coverage.html
COVERAGEJSON=$ROOTDIR/coverage.json
COVERAGEXML=$ROOTDIR/coverage.xml
cd $LOCAL_GOPATH/src/$IMPORTPATH
go get
go test -i
go test -gocheck.v -coverprofile=$COVERAGEOUT | $LOCAL_GOPATH/bin/go2xunit -fail -output $TESTFILE
if [ $? -ne 0 ]; then
exit 1
fi
go tool cover -html=$COVERAGEOUT -o $COVERAGEHTML
if [ $? -ne 0 ]; then
exit 2
fi
mv $LOCAL_GOPATH/bin/$BINARYNAME $ROOTDIR/$BINARYNAME