Skip to content

Commit 616e9a4

Browse files
author
Vaughn Dice
authored
Merge pull request #46 from vdice/build-workflow-cli-in-place
feat(Jenkinsfile): build workflow-cli in place
2 parents 1c600aa + 749647e commit 616e9a4

1 file changed

Lines changed: 65 additions & 11 deletions

File tree

Jenkinsfile

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
def workpath_linux = "/src/github.com/deis/controller-sdk-go"
1+
def workpath_linux_root = "/src/github.com/deis"
22

33
def gopath_linux = {
44
def gopath = pwd() + "/gopath"
55
env.GOPATH = gopath
66
gopath
77
}
88

9-
def workdir_linux = { String gopath ->
10-
gopath + workpath_linux
9+
def workdir_linux = { String gopath, dest ->
10+
gopath + workpath_linux_root + "/" + dest
1111
}
1212

1313
node('windows') {
@@ -31,7 +31,7 @@ node('windows') {
3131

3232
node('linux') {
3333
def gopath = gopath_linux()
34-
def workdir = workdir_linux(gopath)
34+
def workdir = workdir_linux(gopath, "controller-sdk-go")
3535

3636
dir(workdir) {
3737
stage 'Checkout Linux'
@@ -51,7 +51,7 @@ stage 'Go & Git Info'
5151
node('linux') {
5252

5353
def gopath = gopath_linux()
54-
def workdir = workdir_linux(gopath)
54+
def workdir = workdir_linux(gopath, "controller-sdk-go")
5555

5656
dir(workdir) {
5757
checkout scm
@@ -75,11 +75,65 @@ node('linux') {
7575
}
7676
}
7777

78-
stage 'Trigger workflow-cli pipeline with this repo and sha'
78+
stage 'Checkout workflow-cli repo and build/deploy with appropriate updates'
79+
node('linux') {
80+
def repo = "workflow-cli"
81+
def gopath = gopath_linux()
82+
def workdir = workdir_linux(gopath, repo)
83+
84+
// vars/closures around uploading artifacts to gcs
85+
def keyfile = "tmp/key.json"
7986

80-
echo "Passing down SDK_SHA='${git_commit}' and SDK_GO_REPO='${go_repo}' to the Deis/workflow-cli job..."
81-
parameters = [
82-
[$class: 'StringParameterValue', name: 'SDK_SHA', value: git_commit],
83-
[$class: 'StringParameterValue', name: 'SDK_GO_REPO', value: go_repo]]
87+
def getBasePath = { String filepath ->
88+
def filename = filepath.lastIndexOf(File.separator)
89+
return filepath.substring(0, filename)
90+
}
8491

85-
build job: 'Deis/workflow-cli/master', parameters: parameters
92+
def upload_artifacts = { String filepath ->
93+
withCredentials([[$class: 'FileBinding', credentialsId: 'e80fd033-dd76-4d96-be79-6c272726fb82', variable: 'GCSKEY']]) {
94+
sh "mkdir -p ${getBasePath(filepath)}"
95+
sh "cat \"\${GCSKEY}\" > ${filepath}"
96+
sh "make upload-gcs"
97+
}
98+
}
99+
100+
dir(workdir) {
101+
stage "Checkout ${repo}"
102+
git url: "https://github.com/deis/${repo}.git", branch: "master"
103+
104+
stage "Build ${repo}"
105+
if (git_branch != "remotes/origin/master") {
106+
echo "Skipping build of 386 binaries to shorten CI for Pull Requests"
107+
env.BUILD_ARCH = "amd64"
108+
}
109+
sh 'make bootstrap'
110+
111+
stage "Update local glide.yaml with controller-sdk-go repo '${go_repo}' and version '${git_commit}'"
112+
113+
def pattern = "github\\.com\\/deis\\/controller-sdk-go\\n\\s+version:\\s+[a-f0-9]+"
114+
def replacement = "${go_repo.replace("/", "\\/")}\\n version: ${git_commit}"
115+
sh "perl -i -0pe 's/${pattern}/${replacement}/' glide.yaml"
116+
117+
def glideYaml = readFile('glide.yaml')
118+
echo "Updated glide.yaml:\n${glideYaml}"
119+
120+
sh 'make glideup'
121+
sh "VERSION=${git_commit.take(7)} make build-revision"
122+
123+
stage "Deploy ${repo}"
124+
upload_artifacts(keyfile)
125+
}
126+
}
127+
128+
stage 'Trigger e2e tests'
129+
// If build is on master, trigger workflow-test, otherwise, assume build is a PR and trigger workflow-test-pr
130+
waitUntil {
131+
try {
132+
def downstreamJob = git_branch == "remotes/origin/master" ? '/workflow-test' : '/workflow-test-pr'
133+
build job: downstreamJob, parameters: [[$class: 'StringParameterValue', name: 'WORKFLOW_CLI_SHA', value: git_commit]]
134+
true
135+
} catch(error) {
136+
input "Retry the e2e tests?"
137+
false
138+
}
139+
}

0 commit comments

Comments
 (0)