This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild-deploy.yaml
91 lines (84 loc) · 2.46 KB
/
cloudbuild-deploy.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
substitutions:
_GCS_CACHE_BUCKET: salus-cache
_SALUS_PROJECT: salus-template
steps:
# This is ugly because of
# https://github.com/GoogleContainerTools/jib/issues/1500#issuecomment-466207421
- id: FIX_DOCKER
name: gcr.io/cloud-builders/mvn
waitFor: ['-']
dir: /root
entrypoint: bash
args:
- -c
- # Links the Docker config to /root/.docker/config.json so that Jib picks it up.
# Note that this is only a temporary workaround.
# See https://github.com/GoogleContainerTools/jib/pull/1479.
|
mkdir .docker &&
ln -vs $$HOME/.docker/config.json .docker/config.json
volumes:
- name: user.home
path: /root
# Pull down settings file for Artifactory settings
- id: GET_SETTINGS
name: 'gcr.io/cloud-builders/gsutil'
waitFor: ['-']
args: ['cp', 'gs://salus-mavenrepository/m2-settings.xml', '.mvn/settings.xml']
# Load the cached files from GCS if they exist.
- id: PULL_DOWN_CACHE
waitFor: ['-']
name: gcr.io/cloud-builders/gsutil
dir: /root
entrypoint: bash
args:
- -c
- |
(
gsutil cp gs://${_GCS_CACHE_BUCKET}/${_SALUS_PROJECT}-m2-cache.tar.gz /tmp/m2-cache.tar.gz &&
tar -xzf /tmp/m2-cache.tar.gz
) || echo 'Cache not found'
volumes:
- name: user.home
path: /root
- id: DEPLOY
name: 'gcr.io/cloud-builders/mvn'
args: ['deploy', '-s', '.mvn/settings.xml']
volumes:
- name: user.home
path: /root
- id: COMPILE_AND_PUSH_CONTAINER
name: 'gcr.io/cloud-builders/mvn'
env:
- 'SHORT_SHA=$SHORT_SHA'
args:
- compile
# Runs the Jib build by using the latest version of the plugin.
# To use a specific version, configure the plugin in the pom.xml.
- jib:build
# Skip Tests since it happened in the previous test
- "-Dmaven.test.skip=true"
# Ensure we name the image correctly since its not in pom.xml
- "-Ddocker.image.prefix=gcr.io/$PROJECT_ID"
- "-s"
- .mvn/settings.xml
volumes:
- name: user.home
path: /root
# Saves the files to the GCS cache.
- id: PUSH_UP_CACHE
waitFor:
- COMPILE_AND_PUSH_CONTAINER
name: gcr.io/cloud-builders/gsutil
dir: /root
entrypoint: bash
# Caches the local Maven repository.
args:
- -c
- |
set -ex
tar -czf /tmp/m2-cache.tar.gz .m2 &&
gsutil cp /tmp/m2-cache.tar.gz gs://${_GCS_CACHE_BUCKET}/${_SALUS_PROJECT}-m2-cache.tar.gz
volumes:
- name: user.home
path: /root