Adding git hooks to google cloud repo

懵懂的女人 提交于 2020-08-22 17:08:11

问题


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.


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/37818346/adding-git-hooks-to-google-cloud-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!