-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
64 lines (49 loc) · 1.91 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
timeout: 120s
options:
dynamic_substitutions: true
substitution_option: 'ALLOW_LOOSE'
substitutions:
_REGION: 'europe-docker.pkg.dev'
_ARTIFACT_REPO: 'gs://prod-rest_cloudbuild/hello-world'
# $REPO_NAME means GitHub's repo name. It will be container name
_COMMIT_TAG: '${_REGION}/${PROJECT_ID}/test-google-cloud-build/${REPO_NAME}:${SHORT_SHA}'
_LATEST_TAG: '${_REGION}/${PROJECT_ID}/test-google-cloud-build/${REPO_NAME}:latest'
steps:
# собственно собираем джарник
- name: 'maven:3.8.4-eclipse-temurin-17-alpine'
entrypoint: 'mvn'
args: ['package', '-Dmaven.test.skip=true']
dir: 'helloworld'
# распаковываем джарник
- name: 'maven:3.8.4-eclipse-temurin-17-alpine'
entrypoint: 'bash'
args: ['-c', 'mkdir -p target/dependency && (cd target/dependency; jar -xfv ../*.jar) && echo "jar unpack success"']
dir: 'helloworld'
# пулим старый контейнер, если он есть
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker pull ${_LATEST_TAG} || exit 0']
# # проверяем структуру директорий
# - name: 'maven:3.8.4-eclipse-temurin-17-alpine'
# entrypoint: 'find'
# билдим контейнер используя кэш спуленного ранее контейнера,
# на основе указанного докерфайла
- name: 'gcr.io/cloud-builders/docker'
args: ['build',
'-t', '${_COMMIT_TAG}',
'-t', '${_LATEST_TAG}',
'--cache-from', '${_LATEST_TAG}',
'-f', 'Dockerfile',
'.']
artifacts:
objects:
location: '${_ARTIFACT_REPO}'
paths: ['./helloworld/target/h*.jar']
images:
- '${_COMMIT_TAG}'
- '${_LATEST_TAG}'
# example 2
# - name: "alpine"
# args: ['echo', '$_TEST_ENV']
#substitutions:
# _TEST_ENV: Hello World from Alpine STEP in Google Cloud Build.