-
Notifications
You must be signed in to change notification settings - Fork 21
/
Jenkinsfile
executable file
·92 lines (80 loc) · 2.92 KB
/
Jenkinsfile
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!groovy
// https://github.com/feedhenry/fh-pipeline-library
@Library('fh-pipeline-library') _
stage('Trust') {
enforceTrustedApproval('aerogear')
}
@NonCPS
String sanitizeObjectName(String s) {
s.replace('_', '-')
.replace('.', '-')
.toLowerCase()
.reverse()
.take(23)
.replaceAll("^-+", "")
.reverse()
.replaceAll("^-+", "")
}
// The jnlp container will be the one that the configured node will run on
// you can define more containers and run them along-side
def goSlaveContainer = containerTemplate(
name: 'jnlp',
image: 'docker.io/fhwendy/jenkins-slave-go-centos7:201801081225',
args: '${computer.jnlpmac} ${computer.name}',
ttyEnabled: false)
podTemplate(label: 'mobile-cli-go', cloud: "openshift", containers: [goSlaveContainer]) {
node ("mobile-cli-go") {
sh "mkdir -p src/github.com/aerogear/mobile-cli"
withEnv(["GOPATH=${env.WORKSPACE}/","PATH=${env.PATH}:${env.WORKSPACE}/bin"]) {
dir ("src/github.com/aerogear/mobile-cli") {
stage("Checkout") {
checkout scm
}
stage ("Setup") {
sh "go get github.com/golang/dep/cmd/dep"
sh "dep ensure"
sh "go get golang.org/x/tools/cmd/cover"
sh "go get github.com/mattn/goveralls"
}
withCredentials([string(credentialsId: "coveralls_io", variable: 'COVERALLS_TOKEN')]) {
stage ("Build") {
sh "make coveralls_build COVERALLS_TOKEN=${COVERALLS_TOKEN}"
}
}
def project = sanitizeObjectName("mobile-cli-${env.CHANGE_AUTHOR}-${env.BUILD_TAG}")
stage ("Run") {
// workaround because of the https://issues.jboss.org/browse/FH-4471
sh "mkdir -p /home/jenkins/.kube"
sh "rm /home/jenkins/.kube/config || true"
sh "oc config view > /home/jenkins/.kube/config"
sh "oc new-project ${project}"
//end of workaround
sh "./mobile"
}
stage ("Integration") {
sh "oc project ${project}"
sh "go test -timeout 30m -c ./integration"
def labels = getPullRequestLabels {}
def test_short = "-test.short"
if(labels.contains("run long tests")){
test_short = ""
print "Will run the full integration test-suite"
} else {
print "Will run the integration test-suite with -test.short flag"
}
sh "./integration.test ${test_short} -test.v -prefix=test-${sanitizeObjectName(env.BRANCH_NAME)}-build-$BUILD_NUMBER -namespace=`oc project -q` -executable=`pwd`/mobile"
}
stage ("Archive") {
sh "mkdir out"
sh "cp mobile out/"
sh "cp integration.test out/"
sh "cp -R integration out/integration"
archiveArtifacts artifacts: 'out/**'
}
stage ("Clear Project") {
sh "oc delete project ${project}"
}
}
}
}
}