Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud build is not triggered by 'Push to a branch' event, but triggered by 'Pull request' event

Hi all,

I am working on Cloud build event trigger with Git. My current scenario is that when a DEV branch is merged into TEST branch, the cloud build is triggered and starts to build a new TEST version app. But for some reason, the current cloud build is not triggered when the DEV branch is merged. My questions are;

1. The build is triggered for 'Pull request' event setting but not for the 'Push to a branch' event, doesn't the cloud build take the merge as a kind of push event? (e.g. Github Action pull_request, pull_request triggers a push event)

Screenshot 2024-01-16 at 1.04.24 pm.png

This is the build setting, sorry, I cannot post the whole settings as it's not a personal project.

2. Are we able to set the event trigger for 'Pull request' and trigger it after the merge event happened?

3. Can I get other suggestions to trigger the build when DEV is merged into TEST?

 

I appreciate all your advice. Thank you.

1 1 1,546
1 REPLY 1

Hello @user19283045,

To answer your questions:

  1. Take a look at working with branches. The reason why the event is triggered on a "pull request" and not in a "push to a branch" event is because there will be a merge event in YOUR repository, which the event trigger sees. Pushing to a branch on the other hand is not seen by your event trigger because the merge event is happening in the TARGET repository.
  2. You can set the event trigger for Pull request but there is no setting to trigger it after the merge event happened. 
  3. You should work on the TEST branch. Whenever a pull request from the DEV branch happens, a merge event will happen in your repository.
  4. If the above options don't work, you can contact Google Cloud Support to further look into your case. Let me know if it helped, thanks!