Google cloud pipeline example
Google cloud pipeline example — practical walkthrough with examples.
cloudbuild.yaml
This Google Cloud Build pipeline configuration builds a Docker image from a Gradle project, pushes it to Google Container Registry (GCR), and deploys it to Cloud Run. The Docker image tag is extracted from the build.gradle.kts file and passed between build steps using a workspace file.
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
steps:
- id: 'Get wadzpay docker image tag from build.gradle.kts'
name: ubuntu
entrypoint: bash
args:
- -c
- |
# Getting docker image TAG and passing it through further build steps
echo "$(cat build.gradle.kts| grep -e "^version" | cut -d= -f2 | tr -d "\" ")" > /workspace/docker_image_tag.txt
- id: 'Build docker image'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker build -t ${_IMAGE}:$(cat /workspace/docker_image_tag.txt) .']
- id: 'Push docker image to Google Container Registry'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker push ${_IMAGE}:$(cat /workspace/docker_image_tag.txt)']
# Deploy container image to Cloud Run
- id: 'Deploy a new docker version to Cloud Run'
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args: [
'-c',
'gcloud run deploy ${_CLOUD_RUN_SVC_NAME} --image ${_IMAGE}:$(cat /workspace/docker_image_tag.txt) --region ${_REGION} --platform managed --allow-unauthenticated'
]
substitutions:
_IMAGE: "gcr.io/wadzpay-dev/wadzpay-service"
_CLOUD_RUN_SVC_NAME: 'wadzpay-dev-tf'
_REGION: 'europe-west3'
#images:
#- gcr.io/wadzpay-dev/wadzpay-service:${_TAG}
This post is licensed under CC BY 4.0 by the author.