Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
TL;DR
This is mostly a cookbook style article. If you expect more of a theoretical guide, I suggest you to look at the Official Drone Documentation and the Continuous Integration and Continuous Delivery Book
Background story
In my current company, Iâm in charge of the Backend Engineering as well as DevOps side. As you may know, setting up an automated CI/CD pipeline is the prime duty of a DevOps Engineer. Iâm no different.
Historically weâre mostly a Jenkins CI driven company just like most other startups. But weâre heavily cloud enthusiast and distributed development company with scalability in mind. And you know, distributed CI/CD pipeline with Jenkins is not impossible, but hard when you reach at a certain level, as jenkins is almost an ancient (and pioneer) CI/CD tool. Sadly we have reached that level a little bit sooner. So we decided to try something else. Something that fits into our paradigm and adheres to our engineering philosophy.
On the development side, weâre mainly a Golang based company, which proves that we Love Go a lot. We try to use as much Go based open source tools for most of our development needs (and they work great) as we can. So weâve tried couple of CI/CD tools built with Go. We tried Concourse, but it seems too steep to get into the ride. After some mumble jumble (a.k.a initial R&D), we finally reached at Droneâs footprint, an open source CI/CD tool written in Go. At the time of this writing, Drone is quite popular.
Why Drone?
Or may I ask, why not Drone? Itâs a purely distributed, cloud-native, DevOps friendly, team oriented and highly scalable open source CI/CD tool. Phewww, mouth full description, right? If you want to know more about Drone, donât feel shy to head over to the official site.
Iâm pretty excited, so letâs dig deep into the rabbit hole.
Setting up a Drone Server
Drone is mostly a production grade CI/CD server. Unlike Jenkins, it wonât work as intended in your local machine if you donât have a public IP. Drone works best inside cloud VMs, like AWS, DigitalOcean, GCP etc providers VM instances.
Another option is to use Droneâs free Cloud based SaaS, which is fantastic at no cost (and which weâll use in this article). This way you wonât have to waste time to setup the server when youâre in a hurry to test it. Itâs all there waiting for you.
In my future article, I will show you how you can setup a Drone server inside your own private (but public facing) cloud machine for your projects, instead of relying on Drone Cloud.
Impressed? Enough talking.
Now go to https://cloud.drone.io and login with your github account.
It will ask for Github access, since Drone uses Githubâs webhook feature. After login, it will sync your repositories.
Now itâs time for the development setup. For this project I have prepared an example git repo. Fork it and clone it into your local machine. It should work fine. Itâs a Go based project, but you donât need to install Go as weâll not run the project inside our machine.
After weâre done with the development, itâs time to integrate Drone into our development workflow.
Drone integration
Drone uses YML description file for itâs entire pipeline definition. Basically, you write the steps to perform in your pipeline (like fetch from git, build, test, deploy, run etc). Drone will read this file to understand what you want it to perform.
Hereâs our .drone.yml file
kind: pipelinename: default
workspace:base: /gopath: src/github.com/yourname/go-drone-hello-world
steps: - name: testimage: golangcommands: - go get - go test
- name: buildimage: golangcommands: - go get - go build -o output - chmod +x output
- name: runimage: golangcommands: - go get - go build -o output - chmod +x output - ./output
Itâs pretty straight forward, right? Let me describe some pieces of it
We defined a pipeline with several steps. I have splitted test, build, run into separate steps just for the sake of this tutorial. If you read the YML file, you can easily understand what it says. It will fetch, build, test our Github repo inside a Docker container (Drone is completely container based, which is awesome). In this case, weâre using the âgolangâ official docker image for container building. You may guess, you can use your desired language runtime image for your different language projects.
This is the integration part. As weâre using Guithub with Drone, it will automatically start doing itâs job (as described in the YML file) after you commit any changes to your source code (of course inside git repo) and push it to the remote. Github will fire webhook signal then Drone will catch it and do itâs job.
Enough talking, letâs try. Oh by the way, you should click âActivateâ button for your desired git repo in the drone cloud UI. This will activate Droneâs job on that repo.
After selecting âActivateâ, it will give you a whole bunch of customization options, like YML file name, public/private projects, crone jobs, CI/CD build tags for README.md file etc. Cool!
After youâve activated the repo, commit your code and push it to remote origin. Keep an eye on the https://cloud.drone.io main interface/dashboard. You will see Drone picks up your repo within a fraction of second after you pushed and then it has started itâs job.
Youâll see a Yellow Clock animated badge that shows Drone is doing itâs job. Click the repo to see whatâs happening inside.
As you can see, there are a bunch of builds listed there as I have experimented earlier. Youâll see your commit message as the title of each build phase, so pick your commit message wisely.
Click on the latest build.
It shows all the steps exactly as you defined in the YAML file. It will also show color badges for success or failed steps. All of our steps have been passed. Awesome!
If you click on each of the tasks, youâll see what Drone did at that time. very cool UI, isnât it?
Thatâs all for this article. You have just scratched the surface of Drone and the whole CI/CD concept. There are a lot to learn from here. Feel free to explore Droneâs documentation, CI/CD books and setup your own complex projects pipeline and be happy.
Thanks.
Build your own CI/CD pipeline with Drone was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.