adev2086
adev2086

Reputation: 37

Create dependent triggers in GCP cloud build

I need to create a dependent trigger in cloud build. Currently I have two triggers as shown in below image, both of which are created on push event to master branch in respective repos.

'app-engine-test' is triggered on pushing the code to a cloud repository whereas 'seleniumTest' is triggered on pushing code to a Git repository.

However I want to trigger 'seleniumTest' trigger once 'app-engine-test' build is completed. I could not find any such setting in GCP UI.

Can anyone please help?

enter image description here

Upvotes: 1

Views: 1977

Answers (1)

Louis Sayers
Louis Sayers

Reputation: 2219

You may be able to do this by using a Pub/Sub message as the trigger for your dependent build.

When a CloudBuild build runs it publishes messages to a Pub/Sub topic cloud-builds - see https://cloud.google.com/build/docs/subscribe-build-notifications.

So if you have builds app and test, app would be triggered when you push to source control, and test triggered when a message on the cloud-builds topic is published.

I haven't tested this myself, but need something similar so will update this answer as I go. If it turns out you can't subscribe to the cloud-builds event then at the end of the app build you could also publish a message to your own Pub/Sub topic which you could then use to trigger the second build.

Another solution in your case might be to merge the two projects and simply run the selenium tests as a final build step once you've successfully deployed the code.

Upvotes: 2

Related Questions