-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
126 lines (105 loc) · 3.5 KB
/
cloudbuild.yaml
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
steps:
# NOTE: This first ugly step is an optimization. We execute cancel with
# the google provided kubectl container instead of taito-cli, because it
# doesn't need to be pulled before execution -> cancel executes immediately.
- id: ci-cancel
name: 'gcr.io/cloud-builders/kubectl'
entrypoint: 'bash'
env:
- branch_name=$BRANCH_NAME
- commit_sha=$COMMIT_SHA
- build_id=$BUILD_ID
- full_repo_name=$REPO_NAME
- image_path=eu.gcr.io/$PROJECT_ID/$REPO_NAME/client:$COMMIT_SHA
args:
- '-c'
- |
export taito_env
taito_env="$${branch_name}"
if [[ "$${taito_env}" == "master" ]]; then
taito_env="prod"
fi
source ./taito-config.sh
echo "- Get gcloud credentials"
gcloud container clusters get-credentials "$${kubectl_name}" \
--zone "$${gcloud_zone}"
if [[ $$? -gt 0 ]]; then
exit 1
fi
echo "- Cancel all previous ongoing builds targetting the same branch"
# TODO just in case: filter builds that are newer than this build
# --> remeber to implement it also in the taito-cli cancel plugin
gcloud beta container builds list --ongoing | \
grep "$${full_repo_name}@$${branch_name}" | \
grep -v "$${build_id}" | \
cut -d ' ' -f 1 | \
xargs -L1 gcloud container builds cancel
# echo "Delete kube credentials to avoid gcloud/kubectl version mismatch"
# rm -rf ~/.kube
echo "- We ignore all fails during cancel (hence the last echo)"
# ----------------------- Taito-cli ----------------------------------
# Preparing steps
- id: ci-prepare
waitFor: ['-']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-prepare:$BRANCH_NAME', 'src', '$COMMIT_SHA', 'eu.gcr.io/$PROJECT_ID/$REPO_NAME']
env:
- taito_mode=ci
- id: install
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['install:$BRANCH_NAME']
env:
- taito_mode=ci
- id: ci-release-pre
waitFor: ['install']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-release-pre:$BRANCH_NAME']
env:
- taito_mode=ci
- commit_sha=$COMMIT_SHA
- id: ci-test-unit
waitFor: ['install']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-test-unit:$BRANCH_NAME']
env:
- taito_mode=ci
- id: ci-scan
waitFor: ['install']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-scan:$BRANCH_NAME']
env:
- taito_mode=ci
# Build artifacts
- id: ci-docs
waitFor: ['install']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-docs:$BRANCH_NAME']
env:
- taito_mode=ci
- id: ci-build-src
waitFor: ['ci-release-pre']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-build:$BRANCH_NAME', 'src', '$COMMIT_SHA', 'eu.gcr.io/$PROJECT_ID/$REPO_NAME']
env:
- taito_mode=ci
- id: ci-push-src
waitFor: ['ci-build-src']
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-push:$BRANCH_NAME', 'src', '$COMMIT_SHA', 'eu.gcr.io/$PROJECT_ID/$REPO_NAME']
env:
- taito_mode=ci
# Publish and release
- id: ci-publish
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-publish:$BRANCH_NAME']
env:
- taito_mode=ci
- id: ci-release-post
name: 'eu.gcr.io/gcloud-temp1/github-taitounited-taito-cli/cli:latest'
args: ['ci-release-post:$BRANCH_NAME']
env:
- taito_mode=ci
timeout: 600s
images: [
'eu.gcr.io/$PROJECT_ID/$REPO_NAME/src:$COMMIT_SHA'
]