This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
/
pipeline.yml
546 lines (484 loc) · 15.8 KB
/
pipeline.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
resource_types:
- name: pivnet
type: docker-image
source:
repository: pivotalcf/pivnet-resource
tag: latest-final
- name: curl
type: docker-image
source:
repository: pivotalservices/concourse-curl-resource
tag: latest
resources:
- name: operations-manager
type: pivnet
source:
api_token: {{pivnet_token}}
product_slug: ops-manager
product_version: {{operations_manager_regex}}
sort_by: semver
- name: operations-manager-tarball
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "staging/ops-manager/ops-manager-(.*).tar"
- name: elastic-runtime
type: pivnet
source:
api_token: {{pivnet_token}}
product_slug: elastic-runtime
product_version: {{elastic_runtime_regex}}
sort_by: semver
- name: elastic-runtime-tarball
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "staging/elastic-runtime/elastic-runtime-(.*).tar"
- name: stemcell-tarball
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "staging/stemcells/bosh-stemcell-(.*)-.*.tgz"
- name: czero-cflinuxfs2
type: docker-image
source:
repository: pcfnorm/rootfs
tag: latest
- name: czero-cflinuxfs2-tarball
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "staging/czero-cflinuxfs2/czero-cflinuxfs2-(.*)-.*.tar"
- name: czero-cflinuxfs2-tarball-kickstarter
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "czero-cflinuxfs2/czero-cflinuxfs2-(.*)-.*.tar"
- name: pcf-pipelines-tarball
type: pivnet
source:
api_token: {{pivnet_token}}
product_slug: pcf-automation
- name: pcf-pipelines-offline-pinned-tarball
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "staging/pcf-pipelines/pcf-pipelines-v(.*).tgz"
- name: pcf-pipelines-combined
type: s3
source:
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
bucket: {{s3_bucket}}
regexp: "pcf-pipelines-combined/pcf-pipelines-combined-(.*).tar.gpg"
- name: fly
type: curl
source:
url: "((atc_external_url))/api/v1/cli?arch=amd64&platform=linux"
filename: fly
skip_ssl_verification: true
- name: pcf-pipelines-combined-version
type: semver
source:
initial_version: 0.0.0
driver: s3
bucket: {{s3_bucket}}
key: "pcf-pipelines-combined/version"
access_key_id: {{s3_access_key_id}}
secret_access_key: {{s3_secret_access_key}}
endpoint: {{s3_endpoint}}
jobs:
- name: collector
plan:
- aggregate:
- get: pcf-pipelines-tarball
- get: czero-cflinuxfs2
- get: operations-manager
params: { globs: [] }
- get: elastic-runtime
params: { globs: [] }
- put: pcf-pipelines-combined-version
params: { bump: major }
- name: create-ops-manager-tarball
plan:
- aggregate:
- get: pcf-pipelines-combined-version
trigger: true
passed: [collector]
- get: operations-manager
params:
globs: ["*.ova"]
passed: [collector]
- task: create-tarball
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: operations-manager
outputs:
- name: ops-manager-tarball
run:
path: bash
args:
- -c
- |
set -eu
version=$(cat operations-manager/metadata.json | jq --raw-output '.Release.Version')
echo "Creating tarball with version ${version}..."
tar cf "ops-manager-tarball/ops-manager-${version}.tar" -C operations-manager .
- put: operations-manager-tarball
params:
file: "ops-manager-tarball/ops-manager-*.tar"
- name: create-elastic-runtime-tarball
plan:
- aggregate:
- get: pcf-pipelines-combined-version
trigger: true
passed: [collector]
- get: elastic-runtime
passed: [collector]
params:
globs: ["cf*.pivotal"]
- task: create-tarball
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: elastic-runtime
outputs:
- name: elastic-runtime-tarball
- name: stemcell-tarball
params:
PIVNET_API_TOKEN: {{pivnet_token}}
run:
path: bash
args:
- -c
- |
set -eu
stemcell_version=$(
cat ./elastic-runtime/metadata.json |
jq --raw-output \
'
[
.Dependencies[]
| select(.Release.Product.Name | contains("Stemcells"))
| .Release.Version
] | sort | last // empty
'
)
if [ -z "$stemcell_version" ]; then
echo "Expected to find stemcell version in ./elastic-runtime/metadata.json, did not."
exit 1
fi
echo "Downloading stemcell $stemcell_version"
pivnet-cli login --api-token="$PIVNET_API_TOKEN"
pivnet-cli download-product-files -p stemcells -r $stemcell_version -g "*vsphere*" --accept-eula
stemcell_path=$(find . -name *bosh-stemcell-*.tgz)
if [ ! -f "$stemcell_path" ]; then
echo "Stemcell file not found!"
exit 1
fi
mv $stemcell_path stemcell-tarball/
version=$(cat elastic-runtime/metadata.json | jq --raw-output '.Release.Version')
tar cvf "elastic-runtime-tarball/elastic-runtime-${version}.tar" -C elastic-runtime .
- put: elastic-runtime-tarball
params:
file: "elastic-runtime-tarball/elastic-runtime-*.tar"
- put: stemcell-tarball
params:
file: "stemcell-tarball/*.tgz"
- name: create-czero-cflinuxfs2-tarball
plan:
- aggregate:
- get: pcf-pipelines-combined-version
trigger: true
passed: [collector]
- get: pcf-pipelines-tarball
passed: [collector]
- get: czero-cflinuxfs2
passed: [collector]
- task: create-tarball
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: pcf-pipelines-combined-version
- name: pcf-pipelines-tarball
- name: czero-cflinuxfs2
outputs:
- name: czero-cflinuxfs2-tarball
run:
path: bash
args:
- -c
- |
set -eu
version=$(cat pcf-pipelines-combined-version/version)
digest=$(cat czero-cflinuxfs2/digest)
echo "Creating tarball with version ${version}-${digest}..."
tar cf "czero-cflinuxfs2-tarball/czero-cflinuxfs2-${version}-${digest}.tar" -C czero-cflinuxfs2 .
- put: czero-cflinuxfs2-tarball
params:
file: "czero-cflinuxfs2-tarball/czero-cflinuxfs2-*.tar"
- name: publish-kickstarter-czero-cflinuxfs2-after-purge
plan:
- get: czero-cflinuxfs2-tarball
trigger: false
passed: [ create-czero-cflinuxfs2-tarball ]
- put: czero-cflinuxfs2-tarball-kickstarter
params:
file: "czero-cflinuxfs2-tarball/czero-cflinuxfs2-*.tar"
- name: create-offline-pinned-pipelines
plan:
- aggregate:
- get: pcf-pipelines-combined-version
trigger: true
passed: [collector]
- get: czero-cflinuxfs2
passed: [collector]
- get: operations-manager
passed: [collector]
params: { globs: [] }
- get: elastic-runtime
passed: [collector]
params: { globs: [] }
- get: fly
- do:
- get: pcf-pipelines-tarball
passed: [collector]
- task: unpack-pcf-pipelines
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: pcf-pipelines-tarball
outputs:
- name: pcf-pipelines
run:
path: bash
args: ["-c", "tar -xvzf pcf-pipelines-tarball/*.tgz"]
- task: create-pipelines
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: pcf-pipelines-combined-version
- name: czero-cflinuxfs2
- name: operations-manager
- name: elastic-runtime
- name: pcf-pipelines-tarball
- name: pcf-pipelines
- name: fly
outputs:
- name: pcf-pipelines-offline-pinned-tarball
run:
path: bash
args:
- -c
- |
set -o pipefail
set -eu
root=$PWD
chmod +x fly/fly
export PATH="${root}/fly:${PATH}"
opsman_version=$(
cat operations-manager/metadata.json | jq --raw-output '.Release.Version'
)
ert_version=$(
cat elastic-runtime/metadata.json | jq --raw-output '.Release.Version'
)
czero_cflinuxfs2_digest=$(cat czero-cflinuxfs2/digest)
pcf_pipelines_version=$(
cat pcf-pipelines-tarball/metadata.json | jq --raw-output '.Release.Version'
)
combined_version=$(cat pcf-pipelines-combined-version/version)
echo "Pinning resources to specific versions:"
echo " ops-manager -> ${opsman_version}"
echo " elastic-runtime -> ${ert_version}"
echo " pcf-pipelines -> ${pcf_pipelines_version}"
echo " czero-cflinuxfs2 -> ${combined_version}-${czero_cflinuxfs2_digest}"
cat > pin-resource-gets.yml <<EOF
- op: add
path: /jobs/get=pivnet-opsman-product/version
value:
path: "ops-manager/ops-manager-${opsman_version}.tar"
- op: add
path: /jobs/get=pcf-ops-manager/version
value:
path: "ops-manager/ops-manager-${opsman_version}.tar"
- op: add
path: /jobs/get=pivnet-product/version
value:
path: "elastic-runtime/elastic-runtime-${ert_version}.tar"
- op: add
path: /jobs/type=s3/version
value:
path: "czero-cflinuxfs2/czero-cflinuxfs2-${combined_version}-${czero_cflinuxfs2_digest}.tar"
EOF
mkdir -p pcf-pipelines-offline-pinned/install-pcf/vsphere
echo "Creating install-pcf/vsphere/pipeline.yml"
cp pcf-pipelines/install-pcf/vsphere/offline/pipeline.yml pcf-pipelines-offline-pinned/install-pcf/vsphere/pipeline.yml
pcf_pipelines_version=$(
cat pcf-pipelines-tarball/metadata.json | jq --raw-output '.Release.Version'
)
echo "Creating install-pcf/vsphere/params.yml"
cp pcf-pipelines/install-pcf/vsphere/offline/params.yml \
pcf-pipelines-offline-pinned/install-pcf/vsphere/params.yml
echo "Creating unpack-pcf-pipelines-combined/pipeline.yml"
cat > steamroll_config.yml <<EOF
resource_map:
"pcf-pipelines": $root/pcf-pipelines
EOF
mkdir -p pcf-pipelines-offline-pinned/unpack-pcf-pipelines-combined
steamroll -p pcf-pipelines/unpack-pcf-pipelines-combined/pipeline.yml -c steamroll_config.yml \
> pcf-pipelines-offline-pinned/unpack-pcf-pipelines-combined/pipeline.yml
echo "Creating unpack-pcf-pipelines-combined/params.yml"
cp pcf-pipelines/unpack-pcf-pipelines-combined/params.yml \
pcf-pipelines-offline-pinned/unpack-pcf-pipelines-combined/params.yml
echo "Creating offline pinned tarball"
tar czv \
-f "pcf-pipelines-offline-pinned-tarball/pcf-pipelines-${pcf_pipelines_version}.tgz" \
-C pcf-pipelines-offline-pinned \
.
- put: pcf-pipelines-offline-pinned-tarball
params:
file: "pcf-pipelines-offline-pinned-tarball/*.tgz"
- name: create-pcf-pipelines-combined
plan:
- aggregate:
- get: pcf-pipelines-combined-version
trigger: true
passed:
- create-offline-pinned-pipelines
- create-elastic-runtime-tarball
- create-czero-cflinuxfs2-tarball
- create-ops-manager-tarball
- get: pcf-pipelines-offline-pinned-tarball
passed: [create-offline-pinned-pipelines]
- get: stemcell-tarball
passed: [create-elastic-runtime-tarball]
- get: czero-cflinuxfs2-tarball
passed: [create-czero-cflinuxfs2-tarball]
- get: operations-manager-tarball
passed: [create-ops-manager-tarball]
- get: elastic-runtime-tarball
passed: [create-elastic-runtime-tarball]
- task: create-tarball
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: pcf-pipelines-offline-pinned-tarball
- name: pcf-pipelines-combined-version
- name: czero-cflinuxfs2-tarball
- name: operations-manager-tarball
- name: elastic-runtime-tarball
- name: stemcell-tarball
outputs:
- name: pcf-pipelines-combined
params:
GPG_PUBLIC_KEY: {{gpg_public_key_contents}}
GPG_KEY_EMAIL: {{gpg_public_key_email}}
run:
path: bash
args:
- -c
- |
set -o pipefail
set -eu
mkdir -p pcf-pipelines-combined-contents
mv \
czero-cflinuxfs2-tarball/*.tar \
operations-manager-tarball/*.tar \
elastic-runtime-tarball/*.tar \
stemcell-tarball/*.tgz \
pcf-pipelines-offline-pinned-tarball/*.tgz \
pcf-pipelines-combined-contents
echo "Creating SHA manifest..."
pushd pcf-pipelines-combined-contents 1>/dev/null
shasum * > MANIFEST.MF
popd 1>/dev/null
echo ""
version=$(cat pcf-pipelines-combined-version/version)
echo "Importing GPG public key..."
echo "$GPG_PUBLIC_KEY" | gpg --import 2>/dev/null
echo ""
echo "Trusting public key..."
gpg --list-keys --fingerprint --with-colons |
sed -E -n -e 's/^fpr:+([0-9A-F]+):$/\1:6:/p' |
gpg --import-ownertrust 1>/dev/null
echo "Creating encrypted tarball..."
tar cv -C pcf-pipelines-combined-contents . |
gpg \
--output "pcf-pipelines-combined/pcf-pipelines-combined-${version}.tar.gpg" \
--encrypt \
-z 0 \
--recipient $GPG_KEY_EMAIL
echo ""
- put: pcf-pipelines-combined
params:
file: "pcf-pipelines-combined/*.tar.gpg"
- name: purge-minio
plan:
- get: pcf-pipelines-combined-version
- task: purge-minio
config:
platform: linux
image_resource:
type: docker-image
source:
repository: pcfnorm/rootfs
inputs:
- name: pcf-pipelines-combined-version
run:
path: bash
args:
- -c
- |
set -o pipefail
set -eu
aws configure set aws_access_key_id ((s3_access_key_id))
aws configure set aws_secret_access_key ((s3_secret_access_key))
aws configure set default.region us-east-1
for namespace in czero-cflinuxfs2/ elastic-runtime/ ops-manager/ pcf-pipelines-combined/ pcf-pipelines/ staging/ stemcells/; do
aws s3 --endpoint-url ((s3_endpoint)) rm s3://((s3_bucket))/$namespace --recursive
done
aws s3 --endpoint-url ((s3_endpoint)) cp pcf-pipelines-combined-version/version s3://((s3_bucket))/pcf-pipelines-combined/version