Tagged: git

Continuous Integration Pipeline 0

Continuous Integration – Small Story

When a startup starts growing up and have software background, one day or the another there will be a need to build infra for your developers. We at Tagbin are now good in numbers and working on single codebase has become critical.So today I setup a very small continuous integration pipeline.   [If you are interested in more advanced pipeline including Docker & Jenkins that I am currently working on, check this link: https://goo.gl/3Qzw1h ] To start with continuous integration is basically a automated develop-test-build-deploy pipeline.Many tech giants use a complex version of it, but this blog will explain how to get up and running very fast with a small pipeline and trust me this is all you will need to start off. First thing Version Control, there are three alternatives: 1) Git on Github 2) Git on Bitbucket 3) Git on your own server (Try Gitlab http://gitlab.com, its really amazing with almost all the features of GitHub, I will be shifting to it very soon) I choose Bitbucket, the reason being, free unlimited private repository. Second thing is Test Suite: This depends on whatever technology or platform you are working on, you can either run it on your local machine or make it part of deployment pipeline. Finally Deployment: I used Bitbucket’s Web Hook for it. Pipeline Flow: When you done writing code, push it to remote git account(bitbucket in our case),before pushing it to master a test suite will run to check if you are breaking any body’s code and the a final push is made which in turn will fire a WebHook added earlier. This Webhook is basically a script that receives request from bit bucket regarding different events, if the event is a push to master the script will automatically pull the content from the master and put it on development/stagging server based on your configuration.   The Script There is whole big file I wrote that does lot of housekeeping, but the below lines will be enough: <?php exec(‘git config –global credential.helper “cache –timeout=3600” 2>&1’, $output); echo(‘Setting up Password in cache… ‘.implode(‘ ‘, $output)); exec(‘git reset –hard HEAD 2>&1’, $output); echo(‘Reseting repository… ‘.implode(‘ ‘, $output)); //The URL will changes based on where your code is hosted exec(‘git pull https://USERNAME:PASSWORD@bitbucket.org/ACCOUNT/REPOSITORY_NAME.git 2>&1’,$output); echo(‘Pulling content… ‘.implode(‘ ‘, $output)); ?>   Put this php script under any http server, that is accesible publically and is on same machine on which you… Read More