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

Sameer Jaffer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2013

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.

Cheers,

Sameer Jaffer

2 answers

0 votes
Matthew Phillips
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2013

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: https://github.com/ezyang/git-ftp ). 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.

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.
April 17, 2013

Hi Matthew,

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

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

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.

Charles

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.
April 17, 2013

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:

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

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

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events