How do I uses external-hooks with positional parameters?


I'm using Stash 2.8 with external-hook add-on, which can enable to run a external script successfully. But, I cannot know how I use positional parameters.

Actually, I want to pass the sha1 hash, branch name and user name as a parameter of the external script. Could you guide to do this?

3 answers

1 accepted

Hi Hayoung,

That's actually the first I've seen of that plugin. Looking at the code it looks like it's passing in (in order) from hash, to hash, ref id (branch). You should be able to get them via $1, $2 and $3 in your script?

Unfortunately it doesn't look like they're passing in the current user. There isn't much I can do there, you would have to leave a message on the marketplace page. If you manually install raw scripts in the repository pre/post-receive.d hooks directories then Stash will also have set the $REMOTE_USER environment variable which contains the current username.

Generally we recommending using our more powerful Stash hooks, which have access to all this information (and more), although it does mean writing Java.




Maintaner here. Charles was perfectly correct about positional paramers and user name.

I've updated documentation to make clear how to pass arguments.

Also, I've released new version that have possibility of passing user name and email in special environment variables named $STASH_USER_NAME and $STASH_USER_EMAIL.


Thank you very much~

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,745 views 1 5
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