11def workpath_linux = " /src/github.com/deis/workflow-cli"
22def keyfile = " tmp/key.json"
33
4+ def getBasePath = { String filepath ->
5+ def filename = filepath. lastIndexOf(" /" )
6+ return filepath. substring(0 , filename)
7+ }
8+
49def upload_artifacts = { String filepath ->
510 withCredentials([[$class : ' FileBinding' , credentialsId : ' e80fd033-dd76-4d96-be79-6c272726fb82' , variable : ' GCSKEY' ]]) {
11+ sh " mkdir -p ${ getBasePath(filepath)} "
612 sh " cat \"\$ {GCSKEY}\" > ${ filepath} "
713 sh " make upload-gcs"
814 }
@@ -51,6 +57,27 @@ node('linux') {
5157 }
5258}
5359
60+ def git_commit = ' '
61+ def git_branch = ' '
62+
63+ stage ' Git Info'
64+ node(' linux' ) {
65+
66+ def gopath = gopath_linux()
67+ def workdir = workdir_linux(gopath)
68+
69+ dir(workdir) {
70+ checkout scm
71+
72+ // HACK: Recommended approach for getting command output is writing to and then reading a file.
73+ sh ' mkdir -p tmp'
74+ sh ' git describe --all > tmp/GIT_BRANCH'
75+ sh ' git rev-parse HEAD > tmp/GIT_COMMIT'
76+ git_branch = readFile(' tmp/GIT_BRANCH' ). trim()
77+ git_commit = readFile(' tmp/GIT_COMMIT' ). trim()
78+ }
79+ }
80+
5481stage ' Build and Upload Artifacts'
5582
5683parallel(
@@ -62,14 +89,7 @@ parallel(
6289 dir(workdir) {
6390 checkout scm
6491
65- // HACK: Recommended approach for getting command output is writing to and then reading a file.
66- sh ' mkdir -p tmp'
67- sh ' git describe --all --exact-match > tmp/GIT_BRANCH'
68- sh ' git tag -l --contains HEAD > tmp/GIT_TAG'
69- def git_branch = readFile(' tmp/GIT_BRANCH' ). trim()
70- def git_tag = readFile(' tmp/GIT_TAG' ). trim()
71-
72- if (git_branch != " remotes/origin/master" && git_tag == " " ) {
92+ if (git_branch != " remotes/origin/master" ) {
7393 echo " Skipping build of 386 binaries to shorten CI for Pull Requests"
7494 env. BUILD_ARCH = " amd64"
7595 }
@@ -89,11 +109,6 @@ parallel(
89109 dir(workdir) {
90110 checkout scm
91111
92- // HACK: Recommended approach for getting command output is writing to and then reading a file.
93- sh ' mkdir -p tmp'
94- sh ' git describe --all --exact-match > tmp/GIT_BRANCH'
95- def git_branch = readFile(' tmp/GIT_BRANCH' ). trim()
96-
97112 if (git_branch == " remotes/origin/master" ) {
98113 sh ' make bootstrap'
99114 sh ' make build-latest'
@@ -106,3 +121,20 @@ parallel(
106121 }
107122 }
108123)
124+
125+ stage ' Trigger e2e tests'
126+
127+ // If build is on master, trigger workflow-test, otherwise, assume build is a PR and trigger workflow-test-pr
128+ waitUntil {
129+ try {
130+ if (git_branch == " remotes/origin/master" ) {
131+ build job : ' /workflow-test' , parameters : [[$class : ' StringParameterValue' , name : ' WORKFLOW_CLI_SHA' , value : git_commit]]
132+ } else {
133+ build job : ' /workflow-test-pr' , parameters : [[$class : ' StringParameterValue' , name : ' WORKFLOW_CLI_SHA' , value : git_commit]]
134+ }
135+ } catch (error) {
136+ input " Retry the e2e tests?"
137+ false
138+ }
139+ true
140+ }
0 commit comments