Your First Harness CI Installation, Build, and Publish
Your Harness CI journey starts with Drone, a popular Continuous Integration platform. Learn how to get started with your first build and push.
We are very excited to introduce Harness CI to the world. Your Harness CI journey starts with Drone, a popular continuous integration platform. If you are unfamiliar with Drone, Drone is a modern platform designed for low barriers of entry into the Continuous Integration space which connects to your Source Code Management [SCM] platform. If you are unfamiliar with Continuous Integration, don’t worry Harness has you covered and we will be helping everyone gear and strengthen their Continuous Integration capabilities. Harness CI / Drone is simple to get up and running, looking at the architecture there are only a few moving parts.
Harness CI / Drone Architecture
The Harness CI / Drone Server authenticates with your SCM provider and then via a shared secret communicates with the Runners. Wiring up these pieces are pretty simple.
Let’s Get Started
In this example, the moving pieces will be a GitHub Account, a running CentOS machine, a Kubernetes Cluster, and a Docker Hub account. Like always can follow along in the blog and/or watch the video. The example GitHub repository can be cloned/forked before this example at https://github.com/ravilach/firstdrone.
GitHub / SCM Prep
The Harness CI / Drone Server needs to authenticate with your SCM provider. This is accomplished in GitHub by making an OAuth application. This is done by navigating to Settings -> Developer settings -> OAuth Apps + Register a new application.
When you register a new OAuth application, you will need to have the DNS/IP address of the Drone Server handy. In my case this is 220.127.116.11. The callback URL has /login appended to the Homepage URL.
When you register the application, make sure to note the Client ID and Client Secret, which will be needed to wire the Harness CI / Drone Server.
CentOS / HarnessCI/Drone Prep
Depending on where you get CentOS from, you might have to install Docker Engine. Assuming that you have Docker Engine installed, the only piece of prep you need on the server before installing is to generate the shared secret which will be used for Server to Runner communication. Make sure to copy down the shared secret [RPC Secret].
openssl rand -hex 16
Harness CI / Drone Installation.
To get Harness CI / Drone on your machine, simply run a Docker Pull on the image.
sudo docker pull drone/drone:1
Once pulled, you can configure the properties for Docker Run. The properties to fill in for barebones are the secrets and server address and protocol. Let’s go ahead and create an admin user. The admin user follows your GitHub username.
sudo docker run \
One issuing the Docker Run commands with the properties, you can head to the IP or DNS entry of your Harness CI / Drone server. In my case navigate to https://18.104.22.168. You will be greeted to authorize your user via GitHub.
Authorize your GitHub Credentials.
Once Authorized, Harness CI / Drone will build a list of repositories.
Now you are ready to deploy runners, in this case Kubernetes.
Kubernetes Cluster Prep
In this example, we will leverage the Kubernetes Runners. For the Kubernetes Runners to request resources on your behalf, a Role Binding is needed as well as the Runner Deployment.
A simple approach is to build out two YAML files, one for the Role and Role Binding and another for the Deployment.
kubectl apply -f drone_role.yaml
In the Runner Deployment Spec, make sure to update the Drone Server, Shared Secret, and Protocol to match your installation.
When the items are filled in, can deploy the Deployment.
kubectl apply -f drone_deployment.yaml
Optionally you can validate that the Runner is connected to the Server. Get the Pod Name then run a log command.
kubectl get pods --all-namespaces
kubectl logs drone-6564db8f9f-949s2 -c runner
Success! Now would be time to start marching towards your first build.
Marry the CI and SCM Together
Harness CI / Drone leverages Configuration as Code to describe pipelines. Harness CI / Drone can work off of webhook requests from the Source Code Management solution to orchestrate when a new build needs to be kicked off.
Prep the Repository
Can leverage the Harness CI / Drone UI to “Activate” the Repository. In my “firstdrone”, repository, the webhooks are empty.
In the Harness CI / Drone UI, navigate to your repository of choice and then Active Repository.
For the example, the defaults are fine for the Repository Activation. The configuration to modify if needed is the name of the Drone Configuration file to monitor. In this example, you will monitor for “Drone.yaml” in the repository.
Then you can validate that the webhook has been successfully created in GitHub.
With the CI and SCM wirings out of the way, the next steps are to define your first pipeline and fire off a build.
Your First Harness CI / Drone Project
If starting out with an empty repository you can leverage a simple example of a project structure or wire together your own project/repository.
If following this example, you wired into Harness CI / Drone to watch out for “Drone.yaml”. The declarative pipeline format is easy to wire in needed steps and not needing to worry about plug-ins. In the example pipeline, we leverage the Docker Plug-in for the publish setting and well be downloaded automatically during execution time.
The highlighted lines are leveraging secrets to wire in my Docker Hub credentials. You need to update the repo location to your own and create Harness CI / Drone Secrets to wire in.
Back in the Harness CI / Drone UI, navigate to the repository settings, and add the needed secrets.
Add the appropriate secrets to match the format of the example.
With those wirings out of the way, you are now ready to kick off your first build and publish it to Docker Hub.
Your First Build and Publish
With the wirings out of the way, all that is left is to commit the Drone.yaml with some sort of change and you are off to the races.
Once you hit Commit changes, the CI magic starts, and your build and publish are off!
Success! Congratulations on your first Harness CI / Drone build and publish!
Validating success on Docker Hub.
Harness and Drone, Better Together
We are thrilled to further the Harness CI / Drone communities alike. If you want to communicate with the Drone Community, feel free to jump on the Drone Gitter and learn from all the wonderful folks. We have lots of great plans to further CI and CD capabilities alike making them simple and democratized for everyone. Be sure to stay tuned as we announce more updates. Welcome to the Harness family, Drone!