I have a server where our test cases run for all API, which is on the compute engine of GCP. How can I connect it from cloud build CI/CD pipeline so that the CI/CD stage passes only on 200 response status code from the server?
GCP says to create a custom build step (here). Docs are not very clear
You have 2 solutions.
ENTRYPOINT
which will be invoked in the Cloud Build pipeline steps:
- name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
- "-c"
- |
RESPONSE=$(curl -i <YOUR URL> | grep HTTP | cut -d' ' -f2)
if [ "200" != "$$RESPONSE" ]; then exit 1; fi
Note the double $$
to prevent Cloud Build to look into Substitution variables