One of the things that comes with google cloud are git repos. Is it possible to add hooks to this repo? I'd like to incoming pushes, but I don't know how to get access to .git/hooks
.

- 10,296
- 18
- 68
- 110
3 Answers
You can do it if you host your code on git-hub/bitbucket. Then you will be able to use the git hooks.
Google source has this feature (Object Change Notification) instead of hooks: https://cloud.google.com/storage/docs/object-change-notification

- 128,036
- 21
- 144
- 167
-
The change notification is for things in storage buckets, right? Is the source repository feature implicitly in some storage bucket? I didn't think it was. It doesn't show up in the bucket browser anywhere. – pythonic metaphor Jun 14 '16 at 17:49
-
read the first link and see if you can store your code externally – CodeWizard Jun 14 '16 at 17:51
-
1Yes, your method would work. I was hoping there was a way to do so without externally hosting the code – pythonic metaphor Jun 15 '16 at 09:34
You can use the pub/sub notifications instead of the webhook.
In my case, I created a pub/sub which is triggered when the repository is updated. The pub/sub will call a cloud function that makes a post request to codemagic.io CI/CD to initiate a cloud build.
pub/sub notification: https://cloud.google.com/source-repositories/docs/quickstart-adding-pubsub-notifications
You can get the information like the updated branch name, author, etc, in the notification payload. https://cloud.google.com/source-repositories/docs/pubsub-notifications#notification_example

- 641
- 9
- 16
-
-
@hegebut But this is the only way possible with the Google Cloud Source Repository, please suggest if you know any alternate solution. – Soorya Jun 08 '21 at 16:32
Check your server settings, if you use VM not cloud repo of GCloud. https://www.linux.com/LEARN/HOW-RUN-YOUR-OWN-GIT-SERVER You need to install git-core also and add git user to system. I had spended more then day before unserstanding about.

- 315
- 2
- 6