Using Codeship as CI

Hieu Pham
Coffee Techtalk
Published in
2 min readJun 18, 2016

--

As mentioned in Techtalk June 15, 2016, I’m gonna share my experience with Codeship - Continuous Integration and Delivery Made Simple.

I’ll make it short because there are a lot of articles on the internet about Codeship.

Why CI?

My story was

As a person in charge of deploying our web application to various of environments, I should be able to deploy the app by simply clicking the Accept Pull Request button on Bitbucket.

Why Codeship?

  • Jenkins is cool but I’m not good at server stuffs. I’m laaaaazy
  • Cloud service
  • Free (100 builds/mo)

How?

(1) Branch pushes or Pull request accepted

(2) Bitbucket B1 trigger a Codeship webhook.

B1 is the development source code. If you’re familiar with Single Page Application development you might know what does it look like.

(3) Codeship executes the commands

Set up the environment, run the test, run the deploy command, push the built code (minified, uglified, compiled) to Bitbucket B2

Yes, we use another repository just to keep the final code which later can be delivered to app servers.

Codeship is cooler than I thought. It’s not only a CI to run the tests, but also a Continuous Deployment. I call it CI and CD.

(4) App Servers pull the latest code from Bitbucket B2

Actually we’re doing this part by making an SSH connection from Codeship instance to pull the code.

Notes

Using SSH public key of Codeship Instance

Remember to remove all the Deployment Keys of Codeship from the repos. I was wasting my time checking the SSH key over and over again until I found that in an article.

Commands I use

My app is written on AngularJS, along with Bower, GruntJS.

Set up the commands in CodeShip UI is pretty straight-forward. I can easily go through the steps without any problems.

Setup

npm install -g bowernpm install -g grunt-clinpm installnpm install karma grunt-karmabower install

Test

npm test

Deployment

git config — global user.email “mr_hie@yahoo.com” #nobody told me to have this before T_Tgit config — global user.name “Hieu Pham on Codeship” #nobody told me to have this before T_Tgem install sassgem install compassgrunt deploy --env=<your_environment>ssh user@<your_app_server> “cd path/to/app/folder; git pull origin <your_environment>: exit”

It should be noted that:

Hope this help.

--

--

Hieu Pham
Coffee Techtalk

I'm a Frontend Engineer in Singapore. I might care about user experience more than your UX designer · https://hieugoesto.com