forked from GoogleCloudPlatform/DataflowTemplates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
75 lines (69 loc) · 2.26 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
# Google Cloud Build script for Cloud Teleport
#
# This build script is used to build the open-source Cloud Teleport GitHub repository for every
# change pushed. The .m2 directory is cached across steps using a mounted volume and is saved to GCS
# for future runs.
#
# Manual Execution:
# Use the below command to invoke the build manually. Note the substitutions for BRANCH_NAME and
# REVISION_ID. These variables are normally populated when the build is executed via build triggers
# but will be empty during manual execution. Dummy branch and revisions can be passed during manual
# execution so the artifacts can be uploaded upon build completion.
#
# gcloud builds submit . \
# --config=cloudbuild.yaml \
# --substitutions=BRANCH_NAME="master",REVISION_ID="bd671f47ce9e95dce00d0c07aee08f46d65658e4"
#
steps:
###########################################################
# Step 1: Retrieve the cached .m2 directory from GCS
###########################################################
- name: 'gcr.io/cloud-builders/gsutil'
args:
- '-m'
- 'rsync'
- '-r'
- 'gs://${_BUCKET}/cache/.m2'
- '/cache/.m2'
volumes:
- path: '/cache/.m2'
name: 'm2_cache'
###########################################################
# Step 2: Build, Test, and Verify
###########################################################
- name: 'gcr.io/cloud-builders/mvn'
args:
- 'clean'
- 'verify'
- '--batch-mode'
volumes:
- path: '/cache/.m2'
name: 'm2_cache'
env:
- MAVEN_OPTS=-Dmaven.repo.local=/cache/.m2
###########################################################
# Step 3: Update cached .m2 directory on GCS with any
# additional dependencies downloaded during the
# build.
###########################################################
- name: 'gcr.io/cloud-builders/gsutil'
args:
- '-m'
- 'rsync'
- '-r'
- '/cache/.m2'
- 'gs://${_BUCKET}/cache/.m2/'
volumes:
- path: '/cache/.m2'
name: 'm2_cache'
substitutions:
# Default values
_BUCKET: 'cloud-teleport-github_cloudbuild'
artifacts:
# Upload the jars created during the build.
objects:
location: 'gs://${_BUCKET}/artifacts/$BRANCH_NAME/$REVISION_ID'
paths: ['target/*.jar']
options:
# Use higher CPU machines so the caching and build steps are faster.
machineType: 'N1_HIGHCPU_32'