node package manager

git-auto-build

HOW TO USE

This package contains set of scripts to receive queries from Bitbucket and trigger a tutum redeploy.

The following package contains 2 variants:

  • a server that can be built and run with docker: this server will restart other services
  • a server (bitbucket-listener.js) to be used inside an existing docker container. This server receive POST requests from bitbucket and calls a build script

SET ENVIROMENT VARIABLE

The following object map the branch name and its URL to redeploy (see triggers in tutum service)

$ export BRANCHES='{"2klicdev/frontend_v2":{"develop":"https://dashboard.tutum.co/api/v1/service/c2cc22c6-cc43-4b21-a8b8-e74f1e11655a/trigger/4a8d2044-0bff-4a20-98e2-35c92f87a3cb/call/", "master":"https://dashboard.tutum.co/api/v1/service/db75ac943-ce81-426c-9494-1ede9f61533d/trigger/2f5b48e0-6380-3ae-a248-71a520aa4a26/call/"}, "2klicdev/api":{"master":"https://dashboard.tutum.co/api/v1/service/b403f129-f35c-4e83-86eb-b26b37571a19/trigger/dee6a1dc-8a67-42a2-36e-36f113708e30/call/", "develop":"https://dashboard.tutum.co/api/v1/service/46335b54-87ca-4d0c-946a-d21df6b21243/trigger/e5a61282-c610-wbea-9f84-285ccb8add0f/call/"}}'

Webhooks

In Bitbucket, add a web hook that points to this service, ex:

http://git-auto-build.2klic.svc.tutum.io/redeploy

How it works

After setting up the webhook, Bitbucket will send a POST to this service and this service will look at the branch of the commit. If the branch is defined in the environment variable, then it will redeploy the service. mv # Redeploy Script Use this script into docker to detect when a new commit was done. If the commit match to the repository and branch as defined in the environment variable, then redeploy the container

The bitbucket-listener.js is intended to be added to the dockerfile as follow:

$ RUN npm install git-auto-build

Then in a shell script that is called at the container startup, , assuming the code is into /opt/app, add the following command to start the redeploy service:

$ node /opt/app/bitbucket-listener.js