Stash Hook - create or delete file on enable or disable of Hook

Is there a way to write file persistance code on when a hook is disabled or enabled? I have created a post recieve Hook to get parameters from the user but need to persist the values to a file when the hook is enabled and file deleted when the hook is disabled.


Sameer Jaffer

2 answers

Hi Sameer,

I'm afraid to say there really isn't any way you can do this at the moment. Do you mind me asking what you're planning to write to file? In any case you may want to raise a feature request in JIRA so we can track the issue further:

What we could be doing is raising enable/disable events so that such actions can be performed.


Hi Charles,

We're attempting to allow git to execute a hook from the .../[repoid]/hooks/post-receive.d folder. Its a python script (now installed system wide on the server) which executes when called (see: ). We also need to write the configuration file this script needs to .../[repoid]/ftpdata which is input from the user. The actual input is coming from the plugin, which is currently set up as a post-receive-hook plugin in stash. This is for contextual purposes of being able to control this on a per-repository basis and only by users who have sufficient privileges. So essentially, we don't want the post-receive plugin to execute any post-receive stuff as git all ready does this. We just want to be able to enable/disable the plugin and take the needed input from the user from within stash, rather than manipulating the file system manually.

Hi Matthew,

I thought it might be something like that. You might be intested in:

Although it sounds like you're already doing some of the leg-work yourselves.

One alternative would be to execute the script manually from within a post-receive hook just using Java's Runtime.exec() instead of relying on Git. You could tweak the git-ftp scripts slight to take arguments in (from the Settings object) rather than from the configuration file. Not necessarily ideal but would have the desired outcome. Another suggestion would be to FTP in pure Java, but I can understand that would mean rewriting the handy git-ftp scripts.

Sorry I can't be more help.


Suggest an answer

Log in or Join to answer
Community showcase
Jason Wong
Published 10 hours ago in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

221 views 5 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot