Started in 2012, Drone CI is a container-native, event-based, multi-architecture, multi-OS platform for busy teams looking to tighten their software development lifecycles.
Since its acquisition by Harness in August of 2020, Drone CI has made significant improvements in usability and features. Let's see how, in just a few minutes, you can start experimenting with running Drone CI pipelines on any computer running Docker.
Prerequisites
- Be comfortable running commands in the terminal
- GitHub account
- ngrok account
- Computer that can run amd64 or arm64 Docker containers (this includes the new M1-based Macs)
- In your terminal, verify you have
docker
anddocker-compose
commands available
- In your terminal, verify you have
Overview
Drone CI supports multiple SCM solutions, such as GitHub, Bitbucket, Gitea, GitLab and more.
This guide will focus on GitHub. Because we have chosen GitHub, we need to allow GitHub to send webhooks to the Drone CI process on our computer. We will use ngrok to create a tunnel to the internet so our Drone CI process can receive webhook traffic from GitHub.
Create the ngrok
tunnel
- Login to https://ngrok.com
- Open https://dashboard.ngrok.com/get-started/setup, follow the steps to install the
ngrok
binary and connect to your account - Create the tunnel by running
ngrok http 8080
in your terminal, do not stop the process until you are finished with this guide -
ngrok
will create your tunnel and provide you with a URL such ashttps://34f3-146-168-58-81.ngrok.io
Your terminal should display session information similar to this screenshot:
Create the GitHub OAuth Application
- Follow Create an OAuth Application
- For the "Homepage URL", enter the
ngrok
URL from the previous step - For the "Authorization callback URL", enter the same
ngrok
URL, with/login
appended - You will be given the "Client ID" and a "Client secret", make a note of each (the secret is only displayed once, if you misplace it, you will need to generate a new client secret)
- For the "Homepage URL", enter the
Your OAuth application should look similar to this screenshot (for extra authenticity, upload the official Drone CI logo):
Note: ngrok
URLs are temporary with the free plan. If you terminate your ngrok
session and create a new one, your URL will change and you will need to update the "Homepage URL" and "Authorization callback URL" in your OAuth Application.
Start the Drone and Drone Runner processes
The Drone server process requires at least one runner process where pipelines will execute. Drone CI supports multiple runners, but the Docker runner is the most popular.
- Fork the repository https://github.com/jimsheldon/drone-quickstart and clone the forked repository to your computer
- Edit the file
run.sh
- Set
DRONE_GITHUB_CLIENT_ID
andDRONE_GITHUB_CLIENT_SECRET
using the "Client ID" and "Client secret" from the previous section - Set
DRONE_GITHUB_ADMIN
to your GitHub username - Set
DRONE_SERVER_HOST
to yourngrok
URL, without thehttps://
(if yourngrok
URL ishttps://34f3-146-168-58-81.ngrok.io
, setDRONE_SERVER_HOST
to34f3-146-168-58-81.ngrok.io
) - Save your changes
- Set
- Open a new terminal session and change to the directory where you checked out the repository
- Execute
run.sh
by typing./run.sh
and hitting enter - Open your
ngrok
URL in a browser, you should be greeted with "Welcome to Drone"! ๐ - Click "Continue" and you will be asked to authorize your OAuth application
- Next you will see the "Complete your Drone Registration" screen
- Click "Submit" and you will see the Drone CI interface, filter by "quickstart" to see your forked repository
- Click on the repository, then click "Activate Repository"
- Your repository should now be activated
- Execute
Run your first pipeline
- Edit the
.drone.yml
file in the root off your repository. Change theecho hello world
message to something of your choice. If your CPU is amd64 (Intel, AMD) you should remove theplatform
section, which is currently specific to arm64 (Apple M1, Raspberry Pi) - Push your change to a branch and open a pull request
- Your pull request will trigger a check in Drone CI called "continuous-integration/drone/pr"
- Click the "Details" link, you will see your pipeline execution in Drone CI! Click the "hello" step to see your message printed
You now have your very own Drone CI Enterprise installation! Drone CI Enterprise includes a free trial of up to 5,000 builds. To learn more about licensing options, see the Drone CI Enterprise FAQ.
The official Drone CI documentation provides example pipelines in virtually every language. Try it out on one of your own projects!
Teardown
- In the directory where you ran
run.sh
rundocker-compose down
. - In the terminal where your
ngrok
session is running, typeCTRL-C
.
Note: ngrok
URLs are temporary with the free plan. If you terminate your ngrok
session, the next time you run ngrok http 8080
your URL will change, and you will need to update the "Homepage URL" and "Authorization callback URL" in your GitHub OAuth Application, as well as the DRONE_SERVER_HOST
value in run.sh
.
Conclusion
Hopefully this gives you a quick way to get started running Drone CI pipelines from your GitHub repositories.
If you would like to learn more and participate in the Drone CI and Harness communities, here are some helpful links:
- Official Drone CI documentation: https://docs.drone.io
- Harness Slack community: https://harnesscommunity.slack.com (#drone channel)
- Harness community forum: https://community.harness.io
- Harness & Drone User Group: https://www.meetup.com/harness/
- Drone CI official Twitter account: https://twitter.com/droneio
Top comments (1)
Drone is super easy. Thanks for this tutorial