CI/CD Open Source Platform - Drone

Drone是Go语言编写的轻量级CI/CD工具

体验感受

简单说明的话,Drone Server用于接受bitbucket/github等代码托管所发出的webHook并解析代码Root上的.drone.yml文件所配置的自定义程序并传达给连接Server的Agent
来执行实际的测试与部署。
测试与部署的速度很快,而且占用服务器资源很少,这点非常喜欢,不过可惜的是没有并行,比方说apibms 两个项目同时push之后,FIFO的进行处理。

配置说明

DRONE_SECRET: 约定与agent的密钥
8000 端口: WEB Service 端口, 用来看部署情况
9909 端口: Drone Server 端口,用来agent连接
DRONE_SERVER: 指定Drone Server的监听端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// run.sh 创建server 与 agent
docker run -d \
-e DRONE_BITBUCKET=true \
-e DRONE_BITBUCKET_CLIENT=Vs4pNdLp4y7CLCEBRs \
-e DRONE_BITBUCKET_SECRET=8zXEkmzfrRKSTbcCJRcpdzkDCWSeeVpH \
-e DRONE_SECRET=41F386 \
-e DRONE_OPEN=true \
-e DRONE_HOST=https://deployment.example.com \
-e DRONE_ADMIN=kimtaek \
-v /home/ec2-user/workspace/drone:/var/lib/drone \
-p 9909:9000 \
-p 9900:8000 \
--restart=always \
--name=drone \
drone/drone:latest

docker run -d \
-e DRONE_SECRET=41F386 \
-e DRONE_SERVER=被部署IP:9909 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /www:/www \
--restart=always \
--name=agent \
drone/agent:latest

项目Root下的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
workspace:
base: /www/
path: bms

clone:
git:
image: plugins/git
depath: 50
tags: true
when:
branch: master

pipeline:
restore-cache:
image: drillster/drone-volume-cache
restore: true
when:
branch: master
mount:
- dist
- node_modules
volumes:
- bms:/cache

build:
image: node:8.3.0
privileged: true
when:
branch: master
commands:
- npm install
- npm run build
- cp -R /www/bms/dist /drone
- find /www/bms/dist ! -newermt `date '+%Y-%m-%d'` | xargs rm -rf
volumes:
- /www/bms:/drone

rebuild-cache:
image: drillster/drone-volume-cache
rebuild: true
when:
branch: master
mount:
- dist
- node_modules
volumes:
- bms:/cache