This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 249
/
pipeline.yml
81 lines (78 loc) · 2.17 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
---
resource_types:
- name: google-cloud-storage
type: docker-image
source:
repository: frodenas/gcs-resource
resources:
- name: gcs-bucket
type: google-cloud-storage
source:
bucket: YOUR-GCS-BUCKET-NAME
regexp: YOUR-DIRECTORY-AND-FILE-NAME-REGEXP
# e.g. releases/myapp-release-(.*).tar.gz"
json_key: |
# YOUR-JSON-PRIVATE-KEY-OBJECT-GOES-HERE
{
"type": ...,
"project_id": ...,
"private_key_id": ...,
"private_key": ...,
"client_email": ...,
"client_id": ...,
...
}
# To create one for your GCS account, see:
# https://cloud.google.com/storage/docs/authentication#generating-a-private-key
jobs:
- name: 1-build-and-save-release-to-gcs
plan:
- task: create-artifact
config:
platform: linux
image_resource:
type: docker-image
source:
repository: ubuntu
outputs:
- name: build
run:
path: sh
args:
- -exc
- |
# Do your build steps here. Creating temporary file below as a sample:
export CURRENT_TIMESTAMP=$(date +"%Y%m%d%H%S")
echo "Sample build output file, timestamp: $CURRENT_TIMESTAMP" > ./build/myappfile.txt
# Creating sample package file with a file name containing the new version number
tar -cvzf ./myapp-release-$CURRENT_TIMESTAMP.tar.gz --directory=./build .
mv ./myapp-release-*.tar.gz ./build
find .
- put: gcs-bucket
params: { file: ./build/myapp-release-*.tar.gz }
- name: 2-trigger-when-new-file-is-added-to-gcs
plan:
- get: gcs-bucket
trigger: true
passed:
- 1-build-and-save-release-to-gcs
- task: use-new-file
config:
platform: linux
image_resource:
type: docker-image
source:
repository: ubuntu
inputs:
- name: gcs-bucket
run:
path: sh
args:
- -exc
- |
cd ./gcs-bucket
ls -la
echo "Version of release file retrieved: $(cat ./version). Extracting release file..."
tar -xvf ./myapp-release-*.tar.gz
ls -la
cat ./myappfile.txt