9

Does anyone know if there is a mechanism in GitHub:Enterprise to set up a general post-receive hook that will apply to all repositories (including new ones as soon as they are created?)

I am trying to develop a link to a secondary system that will want to get notified of all pushes to all repositories, and requiring manual set-up for each new repository will just be a matter of time before it gets forgotten.

jerryjvl
  • 19,723
  • 7
  • 40
  • 55
  • 3
    Well, the simple solution is to use a script to create the repos on GitHub. I realize this doesn't answer your question, but it is an option. – John Gietzen Aug 30 '12 at 01:58
  • @JohnGietzen, I'll call that "plan B" for now... – jerryjvl Aug 30 '12 at 02:11
  • 3
    Unfortunately, this was one of those things that was a regression when going from GitHub::FI to Enterprise GitHub. Now that they lock down the VM, there isn't any supported way of having a hook apply to all repositories. The only other choice is setting up post-commit hooks on everything, @JohnGietzen is right, using a script and the API is the way to go. Unfortunately, it's also more work for you to get it into place, and doesn't really fix the problem. :-( – John Szakmeister Oct 03 '12 at 09:03
  • I don't think there is anything built in for this, but I have heard that the GitHub:Enterprise team are pretty receptive to feature requests (if they have time). – Moshe Katz Mar 12 '13 at 04:42
  • Possible duplicate of [How can I add a custom git hook to a GitHub Enterprise repo?](http://stackoverflow.com/questions/11385076/how-can-i-add-a-custom-git-hook-to-a-github-enterprise-repo) – feoh Jan 07 '16 at 19:14

2 Answers2

6

I know that this is really old, but GitHub Enterprise 2.6 just came out with pre-receive hooks. More information can be learned here: https://help.github.com/enterprise/admin/guides/developer-workflow/using-pre-receive-hooks-to-enforce-policy/.

This should answer the question originally posted, as this is something that gets set up at an instance level (thus, it is only on GitHub Enterprise) and will work for all repositories.

I am trying to develop a link to a secondary system that will want to get notified of all pushes to all repositories, and requiring manual set-up for each new repository will just be a matter of time before it gets forgotten.

As for this piece, another thing you could look into would be log forwarding on GitHub. You can read about log forwarding here: https://help.github.com/enterprise/admin/articles/log-forwarding. You can also control multiple log forwarding destinations as of version 2.6

brntbeer
  • 353
  • 5
  • 7
-4

GithubCLI is an easy way to interact with GitHub Enterprise and allows you to add post-receive hooks from the command line. Linking this with listing repositories you could have a cron job that makes sure all repositories have a specific post-receive hook.

You could also use the REST API directly or one of the many binding libraries like github_api. For Enterprise it's fairly easy. The API endpoint is http(s)://your-company/api/v3.

It's not an ideal solution, but the API is pretty easy to work with. Hope that helps!

Arthur Maltson
  • 5,760
  • 4
  • 30
  • 33
  • 2
    I'm afraid this is incorrect. GithubCLI will allow you to interact with the Github Enterprise Webhook API, but these are not the same as the kinds of repository hooks you can install when you have filesystem access to the repository. – feoh Jan 07 '16 at 19:10
  • github enterprise post-hook is called webhook, it doesn't any server side hooks other than pre-receive hook – karthikeayan Jul 02 '18 at 18:46