Basically I want to link my cloudbuild.yaml from within my testing environment to my dev environment.
I have a trigger every time I commit on my testing env, my tests run and generate a report (per the yaml). Great.
But I want to create a trigger when my dev environment commits, my tests run from my testing repository and create the reports.
You have 2 solutions for doing this.
First, you can download your test project and run a Cloud Build from the current execution of the dev build
steps:
- name: gcr.io/cloud-builders/git
args: ['clone', 'https://myrepo.com/testing']
- name: gcr.io/cloud-builders/gcloud
args: ["builds", "submit"]
dir: "testing" # I assume that the git clone has created the testing directory
The advantage of this solution is if your Cloud Build on Test project failed, you know it synchronously and you can react on this on your Dev current build
The counterpart is that the processing time is duplicated during the test build. Indeed, the test build is performed, and the dev test continue (even in standby) to wait the test build end. You also need to set correctly the Cloud Build timeout.
Second solution is an API call to trigger manually your test Cloud Build trigger.
For this you need to customize the step bellow with:

You can also change the branchName if you want
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
curl -d '{"branchName":"master"}' -X POST -H "Content-type: application/json" -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://cloudbuild.googleapis.com/v1/projects/<PROJECT_TEST_ID>/triggers/<TRIGGER_UUID>:run
Here, you don't wait the end of the build and you save Cloud Build duration (and money), but you can't react in case of build failed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With