Issue
Refer to Google Cloud documentation Passing data between build steps
It says -
Cloud Build runs your tasks as a series of build steps, which execute in isolated and containerized environments. After each step, the container is discarded. This allows you to have totally different tools and environments for each step, and by default, any data created in one step can't contaminate the next step. But sometimes you may need to persist state from one step of a build to use in subsequent steps.
Now refer to the below cloudbuild.yaml code from Google Cloud Documentation example.
steps:
# Step 1
- name: node
entrypoint: npm
args: ['install']
# Step 2
- name: node
entrypoint: npm
args: ['test']
Question: Why and how the above example runs successfully even if we don’t have a step to install the requirements again in step 2. Because as per my thinking, the step 2 should get fail (but it is not actually) as the installations done in step 1 should get discarded as per the documentation. Thanks!
Solution
The reason both steps succeed is because the command npm install
will download/install the dependencies of your application in a persistent volume in CloudBuild runners which is shared between all of your steps and then the npm test
will run against your app code which is sitting under the same shared volume. This volume name is /workspace
.
Take a closer look at this part of the documentation which will give you more details on how the data is shared between steps: https://cloud.google.com/build/docs/configuring-builds/pass-data-between-steps#passing_data_using_workspaces
Answered By - CaioT Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.