@@ -122,9 +122,11 @@ parallel(
122122
123123stage ' Build and Upload Artifacts'
124124
125- def gcs_bucket = " gs://workflow-cli"
125+ def old_gcs_bucket = " gs://workflow-cli"
126+ def pr_gcs_bucket = " gs://workflow-cli-pr"
127+ def master_gcs_bucket = " gs://workflow-cli-master"
126128
127- def upload_artifacts = { String dist_dir , boolean cache ->
129+ def upload_artifacts = { String dist_dir , String auth_id , String bucket , boolean cache ->
128130 headers = " -h 'x-goog-meta-git-branch:${ git_branch} ' "
129131 headers + = " -h 'x-goog-meta-git-sha:${ git_commit} ' "
130132 headers + = " -h 'x-goog-meta-ci-job:${ env.JOB_NAME} ' "
@@ -136,15 +138,13 @@ def upload_artifacts = { String dist_dir, boolean cache ->
136138
137139 script = " sh -c 'echo \$ {GCS_KEY_JSON} | base64 -d - > /tmp/key.json "
138140 script + = " && gcloud auth activate-service-account -q --key-file /tmp/key.json "
139- script + = " && gsutil -mq ${ headers} cp -a public-read -r /upload/* ${ gcs_bucket} "
140- script + = " && rm -rf /upload/*'"
141+ script + = " && gsutil -mq ${ headers} cp -a public-read -r /upload/* ${ bucket} '"
141142
142143 withCredentials([[$class : ' StringBinding' ,
143- credentialsId : ' 6561701c-b7b4-4796-83c4-9d87946799e4 ' ,
144+ credentialsId : auth_id ,
144145 variable : ' GCSKEY' ]]) {
145146 sh " docker run ${ dist_dir} -e GCS_KEY_JSON=\"\$ {GCSKEY}\" --rm ${ test_image} ${ script} "
146147 }
147- sh " rm -rf ${ tmp_dir} "
148148}
149149
150150def mktmp = {
@@ -171,7 +171,14 @@ parallel(
171171 sh " docker run ${ flags} -e REVISION=${ git_commit.take(7)} ${ dist_dir} --rm ${ test_image} make build-revision"
172172
173173
174- upload_artifacts(dist_dir, true )
174+ upload_artifacts(dist_dir, ' 6561701c-b7b4-4796-83c4-9d87946799e4' , old_gcs_bucket, true )
175+ if (git_branch == " remotes/origin/master" ) {
176+ upload_artifacts(dist_dir, ' 6029cf4e-eaa3-4a8e-9dc7-744d118ebe6a' , master_gcs_bucket, true )
177+ } else {
178+ upload_artifacts(dist_dir, ' 6029cf4e-eaa3-4a8e-9dc7-744d118ebe6a' , pr_gcs_bucket, true )
179+ }
180+ sh " docker run ${ dist_dir} --rm ${ test_image} sh -c 'rm -rf /upload/*'"
181+ sh " rm -rf ${ tmp_dir} "
175182 }
176183 },
177184 latest : {
@@ -181,7 +188,10 @@ parallel(
181188 dist_dir = " -e DIST_DIR=/upload -v ${ tmp_dir} :/upload"
182189 sh " docker run ${ dist_dir} --rm ${ test_image} make build-latest"
183190
184- upload_artifacts(dist_dir, false )
191+ upload_artifacts(dist_dir, ' 6561701c-b7b4-4796-83c4-9d87946799e4' , old_gcs_bucket, false )
192+ upload_artifacts(dist_dir, ' 6029cf4e-eaa3-4a8e-9dc7-744d118ebe6a' , master_gcs_bucket, false )
193+ sh " docker run ${ dist_dir} --rm ${ test_image} sh -c 'rm -rf /upload/*'"
194+ sh " rm -rf ${ tmp_dir} "
185195 } else {
186196 echo " Skipping build of latest artifacts because this build is not on the master branch (branch: ${ git_branch} )"
187197 }
0 commit comments