-
Notifications
You must be signed in to change notification settings - Fork 9
/
cloudbuild.yaml
80 lines (78 loc) · 2.65 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
steps:
- name: gcr.io/cloud-builders/git
id: variables
entrypoint: 'bash'
args:
- -c
- |
# store multiple values as environment variables
# name all values with a common prefix (we'll use "build_")
if [ "$BRANCH_NAME" = "master" ]
then
export build_profile="test"
elif [ "$BRANCH_NAME" = "prod" ]
then
export build_profile="prod"
else
export build_profile="dev"
fi
export build_prefix=""
export build_token=\"$(gcloud auth application-default print-access-token)\"
# write all "build_" variables to the persistent volume "/workspace"
env | grep "^build_" > /workspace/build_vars
#- name: gcr.io/cloud-builders/gcloud
# id: fetch-credentials
# entrypoint: 'bash'
# args: [ '-c', "gcloud secrets versions access latest --secret=apigee-org-admin --format='get(payload.data)' | tr '_-' '/+' | base64 -d > admin.json" ]
- name: node:12
id: "Install Dependencies"
entrypoint: npm
args: ['install', '--silent', '--no-fund']
- name: node:12
id: "Static Code Analysis"
entrypoint: npm
args: ['run', 'lint']
- name: node:12
id: "Unit Test"
entrypoint: npm
args: ['run', 'unit-test']
- name: 'gcr.io/cloud-builders/mvn'
id: "Process Resources"
entrypoint: 'bash'
args:
- -c
- |
# Read environment variables from disk
source /workspace/build_vars &&
mvn -f cloudbuild-pom.xml -ntp process-resources -P${build_profile} -Dorg=$PROJECT_ID -Ddeployment.suffix=${build_prefix} -Dcommit=$COMMIT_SHA -Dbranch=$BRANCH_NAME -Duser.name=cloudbuild
- name: 'gcr.io/cloud-builders/mvn'
id: "Pre-deployment Configurations"
entrypoint: 'bash'
args:
- -c
- |
# Read environment variables from disk
source /workspace/build_vars &&
mvn -f cloudbuild-pom.xml -ntp apigee-config:targetservers -P${build_profile} -Dorg=$PROJECT_ID -Ddeployment.suffix=${build_prefix} -Dbearer=${build_token}
- name: 'gcr.io/cloud-builders/mvn'
id: "Package"
entrypoint: 'bash'
args:
- -c
- |
# Read environment variables from disk
source /workspace/build_vars &&
mvn -f cloudbuild-pom.xml -ntp apigee-enterprise:configure -P${build_profile} -Dorg=$PROJECT_ID -Ddeployment.suffix=${build_prefix}
- name: 'gcr.io/cloud-builders/mvn'
id: "Deploy"
entrypoint: 'bash'
args:
- -c
- |
# Read environment variables from disk
source /workspace/build_vars &&
mvn -f cloudbuild-pom.xml -ntp apigee-enterprise:deploy -P${build_profile} -Dorg=$PROJECT_ID -Ddeployment.suffix=${build_prefix} -Dbearer=${build_token}
- name: node:12
id: "Functional Test"
entrypoint: npm
args: ['run', 'integration-test']