Philip Nguyen
Philip Nguyen

Reputation: 891

How to run a shell script from a Bitbucket "push" webhook?

My question is, how do I run a shell script automatically from a Bitbucket "push" webhook triggering?

I actually only want to run my shell script when my Production branch has new code updates based on the push.

I have looked around, but I am still confused what approach I should take to

I am using Bitbucket/git

My deployment environment: Ubuntu running on an AWS EC2 instance.

Web Software: Nginx, Tomcat7

Other details: My web application is written in Scala/Lift web framework. The batch script I already wrote will simply deploy my code.

  1. Pull from the bitbucket repository
  2. Compile the code (sbt)
  3. Package and deploy the web application.

Thank you

Upvotes: 2

Views: 7104

Answers (2)

Alexandre PENOMBRE
Alexandre PENOMBRE

Reputation: 41

I had the same issue, and I decided to make a light deployer made with Node.js that can run a script on HTTP call. I guess it is very small and easy to configure with your Nginx.

You can grab it there : Node-Webhook-Scripts

I usually run scripts that execute unit tests, and then deploy depending on exit code...

Upvotes: 1

Matt Messersmith
Matt Messersmith

Reputation: 13757

I'm sure there are many ways to accomplish what you're asking, but what I am familiar with is a tool called Jenkins. I'd suggest going with Jenkins, since Bitbucket has Jenkins plugins, and this is likely the easiest option.

We don't do what you're saying, exactly, but we do have automated builds that occur on every push when a new commit is introduced to our Bitbucket repo. Jenkins will run our entire test suite to make sure the change hasn't broken the build. I bet you could trick him into deploying as well, he's a good little butler.

Upvotes: 1

Related Questions