Steps
The basic steps to set-up a Cloud Build in your GCP project is explained here. Assuming that the Cloud Build has been set-up, I will be using this github project to create a pipeline.
Cloud pipeline is typically placed as a yaml configuration in a file named by convention as "cloudbuild.yaml". The pipeline is described as a series of steps, each step runs in a docker container and the name of the step points to the docker image. So for eg. a step which echo's a message looks like this:
Here the name "bash" points to the docker image named "bash" in docker hub
The project does not need to be configured in Google Cloud Build to run it, instead a utility called "cloud-build-local" can be used for running the build file.
git clone git@github.com:bijukunjummen/hello-cloud-build.git cd hello-cloud-build cloud-build-local .Alright, now to add a few more steps. Consider a build file with 2 steps: Here the two steps will run serially, first Step A, then Step B. A sample output looks like this on my machine:
Starting Step #0 - "A" Step #0 - "A": Already have image (with digest): bash Step #0 - "A": Step A Finished Step #0 - "A" 2021/08/10 12:50:23 Step Step #0 - "A" finished Starting Step #1 - "B" Step #1 - "B": Already have image (with digest): bash Step #1 - "B": Step B Finished Step #1 - "B" 2021/08/10 12:50:25 Step Step #1 - "B" finished 2021/08/10 12:50:26 status changed to "DONE"
Concurrent Steps
A little more complex, say if I wanted to execute a few steps concurrently, the way to do it is using waitFor property of a step.Starting Step #1 - "B" Starting Step #0 - "A" Step #1 - "B": Already have image (with digest): bash Step #0 - "A": Already have image (with digest): bash Step #1 - "B": Step B Step #0 - "A": Step A Finished Step #1 - "B" 2021/08/10 12:54:21 Step Step #1 - "B" finished Finished Step #0 - "A" 2021/08/10 12:54:21 Step Step #0 - "A" finished
No comments:
Post a Comment