10

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.

pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110

3 Answers3

3

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

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
2

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

Soorya
  • 641
  • 9
  • 16
  • you won't be able to reject changes with pub/sub notifications – hege Jun 08 '21 at 15:05
  • @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
0

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.

BebnevRoman
  • 315
  • 2
  • 6