Add a Post-Merge Hook to Repository

Hello,

I would like to be able to add a post-merge like hook that would ssh into a production web server and pull changes from a repository that has had a pull request merged into it. I've read all the other posts on this and I see that a webhook is the most recommended method. However I am not comfortable with publishing a page that executes code on my public-facing server. Is there another way to use a webhook that I'm unaware of that would prevent potential unauthorized code execution on my public-facing server?

I am quite surprised that this isn't a feature that has been made more accessible (i.e. without having to write my own add-on) to paying customers. It seems like this should be a standard part of the hooks available to Stash.

Anyway, any insight would be greatly appreciated.

-Tim.

6 answers

1 accepted

0 vote

Hi Tim,

Stash Pull Requests use 'git merge' command for sure.

Kind regards,
Felipe Kraemer

You should write a plugin that has a listener to PullRequestMergedEvent and does the SSH/deployment you need in the event handler.

As I alluded to in my original post, I was hoping to avoid having to learn Java, learn the Atlassian libraries, and then write my own plugin. I just don't have the time at the moment.

As a workaround, I was able to get a webhook add-on to do what I needed by locking down a specific port on my webserver to only allow traffic from my development server's ip address.

But like I said, this sort of functionality seems like it should just be part of the out-of-box functionality.

0 vote

Hi Tim,

Maybe you don't need to write a plugin, but configure a Git post-merge hook?

http://git-scm.com/docs/githooks

If this answer was helpful, please allow me to ask you to mark my answer as accepted in order to have it in the top of the thread, also helping other customers.

Thanks in advance!

Kind regards,
Felipe Kraemer

That's not a bad idea. I had the same thought, but I wasn't sure I could do that without interfering with Stash's operations. Also, I've read elsewhere that a merge from a Stash Pull Request doesn't actually use the 'merge' command. Can you shed a little more light on this?

 

Thanks!

-Tim.

Interesting, I'll have to play around with this. Thanks for your insight!

 

-Tim.

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...

2,007 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