-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
108 lines (89 loc) · 2.49 KB
/
Jenkinsfile
File metadata and controls
108 lines (89 loc) · 2.49 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
def workpath_linux = "/src/github.com/deis/workflow-cli"
def keyfile = "tmp/key.json"
def upload_artifacts = { String filepath ->
withCredentials([[$class: 'FileBinding', credentialsId: 'e80fd033-dd76-4d96-be79-6c272726fb82', variable: 'GCSKEY']]) {
sh "cat \"\${GCSKEY}\" > ${filepath}"
sh "make upload-gcs"
}
}
def gopath_linux = {
def gopath = pwd() + "/gopath"
env.GOPATH = gopath
gopath
}
def workdir_linux = { String gopath ->
gopath + workpath_linux
}
node('windows') {
def gopath = pwd() + "\\gopath"
env.GOPATH = gopath
def workdir = gopath + "\\src\\github.com\\deis\\workflow-cli"
def pscmd = { String cmd ->
"powershell -NoProfile -ExecutionPolicy Bypass -Command \"${cmd}\""
}
dir(workdir) {
stage 'Checkout Windows'
checkout scm
stage 'Install Windows'
bat pscmd('.\\make bootstrap')
stage 'Test Windows'
bat pscmd('.\\make test')
}
}
node('linux') {
def gopath = gopath_linux()
def workdir = workdir_linux(gopath)
dir(workdir) {
stage 'Checkout Linux'
checkout scm
stage 'Install Linux'
sh 'make bootstrap'
stage 'Test Linux'
sh 'make test'
}
}
stage 'Build and Upload Artifacts'
parallel(
revision: {
node('linux') {
def gopath = gopath_linux()
def workdir = workdir_linux(gopath)
dir(workdir) {
checkout scm
// HACK: Recommended approach for getting command output is writing to and then reading a file.
sh 'mkdir -p tmp'
sh 'git rev-parse --abbrev-ref HEAD > tmp/GIT_BRANCH'
sh 'git tag -l --contains HEAD > tmp/GIT_TAG'
def git_branch = readFile('tmp/GIT_BRANCH')
def git_tag = readFile('tmp/GIT_TAG')
if (git_branch != "master" && git_tag == "") {
echo "Skipping build of 386 binaries to shorten CI for Pull Requests"
env.BUILD_ARCH = "amd64"
}
sh 'make bootstrap'
sh 'make build-revision'
upload_artifacts(keyfile)
}
}
},
latest: {
node('linux') {
def gopath = gopath_linux()
def workdir = workdir_linux(gopath)
dir(workdir) {
checkout scm
// HACK: Recommended approach for getting command output is writing to and then reading a file.
sh 'mkdir -p tmp'
sh 'git rev-parse --abbrev-ref HEAD > tmp/GIT_BRANCH'
def git_branch = readFile('tmp/GIT_BRANCH')
if (git_branch == "master") {
sh 'make bootstrap'
sh 'make build-latest'
upload_artifacts(keyfile)
} else {
echo "Skipping build of latest artifacts because this build is not on the master branch (branch: ${git_branch})"
}
}
}
}
)