Drone CI 流水线与命令行
Drone 用 .drone.yml 描述容器化流水线,每个 step 是一个容器。它适合自托管场景,配置简洁,但生态和托管服务与 GitHub Actions 不同。
drone build ls octocat/hello
drone build info octocat/hello 42
drone build promote octocat/hello 42 production
drone repo ls
drone secret add --repository octocat/hello --name docker_password --data "$PASSWORD"
drone lint .drone.yml
drone exec --pipeline default
最小配置:
kind: pipeline
type: docker
name: default
steps:
- name: test
image: node:20
commands:
- npm ci
- npm test
- name: build
image: plugins/docker
depends_on: [test]
settings:
repo: octocat/hello
tags: latest
username:
from_secret: docker_username
password:
from_secret: docker_password
.drone.yml 的 kind/type 与实际 Runner 类型要匹配;docker、kubernetes、exec 配置不同。depends_on 顺序执行;不写依赖时不要假设执行顺序。from_secret;直接写明文会进仓库历史。when 条件和分支/tag 匹配要测试;不匹配的构建根本不会触发。latest 会让构建结果漂移。github-actions — GitHub 流水线gitlab-ci — GitLab 流水线docker — 容器运行时