2020-06-05 21:05:57 +00:00
# Drone CI for Cloudron
Run the Drone server on Cloudron and the agents locally.
I am using this setup together with a Gitea running on the same Cloudron installation.
2020-06-06 07:15:28 +00:00
## What is Sponsorware?
2020-06-06 07:21:56 +00:00
This project is published as Sponsorware. Which means it is (at first) only available for those that sponsor my work (for example [on Github ](https://github.com/sponsors/fbartels )) and therefore allow me to spent time on it. I have collected some thoughs on [Sponsorware on my blog ](https://blog.9wd.eu/posts/sponsorware/ ).
2020-06-06 07:15:28 +00:00
2020-06-05 21:05:57 +00:00
## Requirements
2020-07-22 05:54:27 +00:00
- `docker-compose` (on the system where you want to run the agent)
2020-06-05 21:05:57 +00:00
- `git`
2020-07-22 05:54:27 +00:00
- `jq`
2020-06-05 21:05:57 +00:00
- `make`
- Cloudron CLI
2020-06-06 06:55:23 +00:00
## Installation
2020-07-21 05:44:18 +00:00
- Run `DOCKER_REPO=your-docker-hub-user make install` to install the Drone server component at `drone.yourdomain.com` (`yourdomain.com` automatically adapts to your Cloudron setup)
2020-06-06 06:55:23 +00:00
- Run `make exec` to open the cli of the app and modify `.env` so that it can connect to your Git instance
- Run `cloudron restart` to restart the app and apply your changes
- Verify that your setup works by going to `https://drone.yourdomain.com`
2020-10-08 13:02:29 +00:00
- If all looks good run `runner/start.sh` to start the Drone agent on your local machine (will fetch credentials from the installed app directly)
2020-06-06 06:55:23 +00:00
- Add the Drone configuration to your desired repositories
2020-06-05 21:05:57 +00:00
## Tips and Tricks
I would also like to share some very useful commands. To install `drone` CLI, follow [official docs ](https://docs.drone.io/cli/install/ ).
### Using drone-cli
Go to your [user settings ](https://drone.9wd.eu/account ) and get login information
```bash
export DRONE_SERVER=https://drone.9wd.eu
export DRONE_TOKEN=your token
drone info
```
### Executing pipelines directly
You can also run pipelines directly with the Drone CLI:
```bash
2020-10-17 20:43:08 +00:00
drone exec --secret-file secrets.txt .drone.yml
2020-06-05 21:05:57 +00:00
```
2020-10-17 20:43:08 +00:00
A template for `secrets.txt` :
2020-06-05 21:05:57 +00:00
2020-10-17 20:43:08 +00:00
```bash
slack_url=https://hooks.slack.com/services/xxxxxxxxxxxx
2020-06-05 21:05:57 +00:00
```
### Adding secrets through CLI
You can either add secrets through the web UI or use drone directly from your terminal:
```bash
drone secret add -repository username/repository-name --name foo --data bar --allow-pull-request
```
2020-10-18 17:37:53 +00:00
### Trigger build via curl
```bash
curl -X POST -i https://drone.9wd.eu/api/repos/felix/cloudron-drone-app/builds -H "Authorization: Bearer your-token"
```
Get token from https://drone.9wd.eu/account
2020-06-05 21:05:57 +00:00
## Inspiration
- [Setting up simple, self-hosted & fast CI/CD solution with Drone.io ](https://webhookrelay.com/blog/2019/02/11/using-drone-for-simple-selfhosted-ci-cd/ )
2020-06-05 21:09:32 +00:00
- [official Drone documentation ](https://docs.drone.io/server/provider/gitea/ )