Drone CI 中文文档

安装 VM Runner

VM Runner 处于候选发布阶段。

本文介绍了如何在 Linux 上安装 VM RunnerVM Runner 打包为一个最小的 Docker 镜像,存放在 DockerHub.

驱动程序(Drivers)

VM Runner 支持多个驱动程序,请参阅页面底部的链接或驱动程序部分以获取其特定设置信息。

默认情况下,我们使用 Amazon 驱动程序

下载 VM Runner/AWS Runner 镜像

安装 Docker 并拉取 VM Runner/AWS Runner 镜像:

1
docker pull drone/drone-runner-aws

配置 VM Runner

可以使用环境变量配置 VM Runner。本文引用了以下配置选项。有关配置选项的完整列表,请参阅 VM Runner 配置参数

  • DRONE_RPC_HOST
    提供 Drone Server 的主机名(和可选端口)。Runner 连接到指定主机地址的 Server 以接收 Pipeline 以执行。: 提供 Drone Server 的主机名(和可选端口)。Runner 连接到指定主机地址的 Server 以接收 Pipeline 以执行。
  • DRONE_RPC_PROTO
    提供用于连接 Drone Server 的协议。该值必须是 httphttps
  • DRONE_RPC_SECRET
    提供用于向 Drone Server 进行身份验证的共享密钥。这必须与你的 Drone Server 配置中定义的 Secret 匹配。
  • DRONE_MIN_POOL_SIZE (可选)
    提供 Pool(资源池)的最小大小。Pool(资源池)不会缩小到此大小以下。默认值为 1。
  • DRONE_MAX_POOL_SIZE (可选)
    提供 Pool(资源池)的最大大小。Pool(资源池)不会超过这个大小。默认值为 2。
  • DRONE_ENABLE_AUTO_POOL (可选)
    Runner 将尝试根据其操作系统信息将您的 Pipeline 与 Pool(资源池)匹配。不需要在 Pipeline 中设置 Pool(资源池)名称。默认值为 false

Amazon EC2 先决条件

默认情况下,Runner 需要两个额外的 Amazon 特定环境变量。有关更多信息,请查看 Amazon 的特定配置选项。

  • AWS_ACCESS_KEY_ID
    由你的 AWS 账户提供的 Access Key ID。这必须具有创建和运行 EC2 实例的权限。
  • AWS_SECRET_ACCESS_KEY
    由你的 AWS 账户提供的 Secret Access Key。参考 aws secret
  • AWS_DEFAULT_REGION (可选)
    由你的 AWS 账户提供的默认区域设置。默认为 us-east-2

安装 VM Runner

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
docker run --detach \
  --env=DRONE_RPC_PROTO=https \
  --env=DRONE_RPC_HOST=drone.company.com \
  --env=DRONE_RPC_SECRET=super-duper-secret \
  --env=DRONE_RUNNER_CAPACITY=2 \
  --env=DRONE_RUNNER_NAME=my-first-runner \
  --env=AWS_ACCESS_KEY_ID=your-access-key \
  --env=AWS_ACCESS_KEY_SECRET=your-access-secret \
  --publish=3000:3000 \
  --restart=always \
  --name=runner \
  drone/drone-runner-aws

这将在名为 testpool 的 Pool(资源池)中启动 us-east-2 区域中的 2 个 Ubuntu 实例。

验证安装结果

使用 docker logs 命令查看日志并验证 Runner 是否成功与 Drone Server 建立连接。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
$ docker logs runner

level=info msg="daemon: starting the server" addr=":3000"
level=info msg="daemon: successfully connected to aws"
level=info msg="daemon: successfully pinged the remote drone server"
level=debug msg="check pool" pool=ubuntu
level=info msg="daemon: polling the remote drone server" capacity=2 endpoint="http://172.21.97.69:8080" kind=pipeline type=aws
level=debug msg="poller: request stage from remote server" thread=2
level=debug msg="poller: request stage from remote server" thread=1
level=debug msg="check pool" pool="windows 2019"
level=debug msg="provision: creating instance" adhoc=false ami=ami-0840994b9b4c03cb1 pool="windows 2019"
level=debug msg="instance create" image=ami-0840994b9b4c03cb1 region=us-east-2 size=t2.medium
level=info msg="instance create success" id=i-08bb839ae0fc19524 image=ami-0840994b9b4c03cb1 region=us-east-2 size=t2.medium
level=debug msg="check instance network" image=ami-0840994b9b4c03cb1 name=i-08bb839ae0fc19524 region=us-east-2 size=t2.medium
level=debug msg="check instance network" image=ami-0840994b9b4c03cb1 name=i-08bb839ae0fc19524 region=us-east-2 size=t2.medium
level=debug msg="instance network ready" id=i-08bb839ae0fc19524 image=ami-0840994b9b4c03cb1 ip=18.119.101.233 region=us-east-2 size=t2.medium
level=info msg="provision: created the instance" adhoc=false ami=ami-0840994b9b4c03cb1 id=i-08bb839ae0fc19524 ip=18.119.101.233 pool="windows 2019" time(seconds)=61.8857165
level=debug msg="provision: Instance responding" adhoc=false ami=ami-0840994b9b4c03cb1 id=i-08bb839ae0fc19524 ip=18.119.101.233 pool="windows 2019"
level=debug msg="provision: complete" adhoc=false ami=ami-0840994b9b4c03cb1 id=i-08bb839ae0fc19524 ip=18.119.101.233 pool="windows 2019"
level=info msg="buildPools: created instance windows 2019 i-08bb839ae0fc19524 18.119.101.233"
level=info msg="daemon: pool created"

If the runner is unable to create an instance in Amazon, we have a setup command to help check the AWS configuration, see Amazon Setup.

高级配置项目

有关高级运行器配置选项的更多信息,请参阅 VM Runner 配置参数

有关高级 Pool(资源池)配置选项的更多信息,请参阅 Pool

有关使用 Amazon 驱动程序 的更多信息。

有关使用 Anka 驱动程序 的更多信息。

有关使用 Azure 驱动程序 的更多信息。

有关使用 Digital Ocean 驱动程序 的更多信息。

有关使用 Google 驱动程序 的更多信息。