Continuous Integration and Deployment through Circle CI

Ayushi Gupta
5 min readFeb 3, 2018


On small or casual projects, developers can do tasks manually with regards to building projects, testing and deployment. But this quickly creates a very big headache when you reach to a point of complexity or have big team of developers working together. on same project

Missing any steps along the way can cause multiple issues, like incorrect merge or a code block being change by someone and breaking other components, unit tests not being properly run, or forgetting to upload a file during a deployment (yuck!) which can bring down an entire projectbuild.

We use various tools like earlier we had Buddy Build Integration but as we migrated to higher API versions it became useless.So requirement came up for something which does the same but at the same time no dedicated server being required along with the pricing factors when we just had a single app with less build time.

CircleCI came out to be a best fit for all our requirements.Let’s checkout out the CircleCi workflow:

  • Developer completes the task development and push it into repository.
  • Repository sends a web hook request to Circle Ci system.
  • Circle CI server executes process like setting up complete environment,cache ,test building apk(added for specific usage at Rubique), uploading it to Slack(can be google drive or firebase depending upon the need).
  • CI server runs job (tests, coverage, check syntax and others)
  • CI server releases saved artifacts for testing
  • If the build or tests fail, the CI server alerts the team
  • The team fixes the issue

Many tools are present for continuous integration and deployment like Jenkins, Travis CI etc. But some interesting features of Circle CI make it suit to your requirement if you want to complete integration in short span of time.

  • Circle Ci is a cloud based system hence no requirement of setting up a dedicated server, no dev-ops requirement.
  • It has a free plan even for a business account , around 1500 build minutes free per month .
  • Rest API — you have an access to projects, build and artifacts The result of the build is going to be an artifact or the group of artifacts. Artifacts could be a compiled application or executable files (e.g. android APK) or meta data (e.g. information about the tests`success).
  • Circle CI caches requirements installation. It checks all the 3rd party dependencies initially instead of constant installations of the environments needed.
  • You can trigger SSH mode to access container and make your own investigation (in case of any problems appear).
  • So it’s a complete out of a box solution that needs minimal configuration\adjustments.

Circle CI compatiblity:

  • Python, Node.js, Ruby, Java, Go, etc.
  • Ubuntu (12.04, 14.04), Mac OS X (paid accounts).
  • Github, Bitbucket.
  • AWS, Azure, Heroku, Docker, dedicated server.
  • Jira, HipChat, Slack.

Circle CI Pros:

  • Circle CI has a free plan for enterprise projects.
  • It’s easy and fast to start.
  • Lightweight, easily readable YML config.
  • You do not need any dedicated server to run Circle CI.

Circle CI Cons:

  • Circle CI supports only 2 versions of Ubuntu for free (12.04 и 14.04) and Mac OS as a paid part.
  • Despite the fact Circle CI do work with and run on all languages it supports only the following programming languages “out of the box”:

Go , Haskell, Java, PHP, Python, Ruby/Rails, Scala

  • Some problems may appear in case you would like to make customizations: you may need some 3rd party software to make those adjustments.
  • Also, while being a cloud-based system is a plus from one side, it can also stop supporting any software, and you won’t be able to prevent that.

Circle CI set up:

Getting started with Circle CI was easy, just need to login with Bitbucket or Github account.Once login is done need to manage the projects and then set it up.

Choose the environment you wish to work upon,we chose Linux for our app and started building the needfuls.

CONFIG Walkthrough

Circle CI is easy just need to add a config file that satisfies all the requirements.At Rubique we chose:


In config we have a jobs key. Each job represents a phase in your Build-Test-Deploy process. Our app only needs a build job, so everything else is going to live under that key. In each job, we have the option of specifying a working_directory. This is the directory into which our code will be checked out, and this path will be used as the default working directory .

- image: circleci/android:api-27-alpha

We use the CircleCI-provided Android image with the api-27-alpha tag it directly links to our compileSDKVersion.

After that add several steps within the build job.We start with checkout so we can operate on the codebase.Next we pull down the cache, if present. If this is going to be your first run, or if you’ve changed either of your build.gradle files, this won’t do anything. We run ./gradlew androidDependencies next to pull down the project’s dependencies. Normally you never call this task directly since it’s done automatically when it’s needed, but calling it directly allows us to insert a save_cache step that will store the dependencies in order to speed things up for next time.

Build Apk
command: ./gradlew build -PpreDexEnable=false -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xms3584m -Xmx3584m"

We added specific task to build Apk and then modifed the function so that it runs in 4g environment of Circle CI else GC overhead error stops the execution of script if your app required more than 4gb.If needed more you can connect to Circle CI team.

Then ./gradlew lint test runs the unit tests, and runs the built in linting tools to check your code for style issues.

At Rubique we use Slack for all our internal communication , so added one more process to upload this apk on slack automatically so that testers can directly access it.Slack has nice support of Circle CI integrated. If want we can upload apk on firebase or google drive as per requirements.

For Slack it requires Slack token and slack channel name .

- run:
Upload to Slack
command: |
export apk_name="build-${CIRCLE_BRANCH}-`git rev-parse --short HEAD`.apk"
curl -F token="${SLACK_TOKEN}" -F channels="${SLACK_CHANNEL}" -F title="${apk_name}" -F filename="${apk_name}" -F file=@app/build/outputs/apk/debug/app-debug.apk

If all goes well then you can check every step result at Circle CI console.Once done successful the build will be directly uploaded on Slack.

At Rubique we believe to deliver financial services at ease to our user so Circle CI facilitates it by giving us all overview of errors or warnings in the project so the team can fix it and deliver seamlessly to users.