Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Use GIT Hooks with stash?

Jochen Häberle September 24, 2013

Is it possible to use GIT hooks in .git/hooks/ with Stash?

It would like to know if I can write a simple shell script for the post-receive hook to be run by the server on a git push. It should check out a branch to a webserver.

I was not able to find a word on this anywhere.

Thanks in advance, regards from munich

Jochen

2 answers

1 accepted

2 votes
Answer accepted
Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2013

Hi Jochen,

You can use standard git hook scripts with Stash (in addition to Java-based hooks). Just pop them in the <STASH_HOME>/data/repositories/<repo-id>/hooks/post-receive.d directory.

Cheers,

Michael

Jochen Häberle September 24, 2013

Thx! I will give it a try!

Cheers,

Jochen

Kenneth Olwing November 3, 2013

Sorry for butting in...is there more in depth documentation on this subject somewhere?

Some specific questions off the top of my head:

  1. Is there any location where I can place standard git hook scripts so they automatically get placed in (post|pre)-receive.d when new repos get created?
    (Yes, Java based hooks are nice, but I have a few Perl hooks I can't discard at the moment).

  2. Can I on a global/project level mandate the use of one or more (Java based) hooks for 'all' repos (or 'all' in a given project). As a sysadmin mandate, can I protect them from being disabled for certain repos?

  3. Is there any UI to allow me to simply work with hooks for a set of repos, i.e. looking at a list of 133 repos, I'd like to check 57 and then 'enable hook X for all checked'.

I can probably work around things in various ways, but in case there are existing ways to achieve them, it'd be nice(r)...

Thanks,

ken1

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2013

Hi Kenneth,

There isn't really any documentation about managing raw Git hooks, possibly because it's not necessarily something Stash wants to encourage.

1. I believe you should be able to add them to the global Git templates directory, which is used when new Git repositories are created in Stash. I would recommend using symlinks to the actual script so that when the file is _copied_ it will be a copy of the symlink and not the actual file (which will then get out of sync).

2. Not at the moment. This is something that's a more general problem for most of the repository settings, not just hooks. This might be a good feature request to follow:

https://jira.atlassian.com/browse/STASH-3597

3. Again, not at the moment. Your best bet would be to use our REST api from a local script:

https://developer.atlassian.com/static/rest/stash/latest/stash-rest.html#idp2683712

Cheers,

Charles

Kenneth Olwing December 1, 2013

Thanks Charles, I'll investigate.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2013

One thing I forgot to mention - if you do create the templates in the global templates directory make sure you add them to pre-receive.d or post-receive.d, otherwise they won't work.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events