Drone的一些使用

Drone的一些使用

1. CLI Reference

1.1 Configuration

Configuration

在Drone图形界面登陆后,User settings中存在Personal Token、API和CLI使用示例以及

Configure your Drone server address:

export DRONE_SERVER=http://drone.mycompany.com

Configure your Drone personal token:

export DRONE_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

2. secret

2.1 可以在repo界面添加

Per Repository

在这里插入图片描述

kind: pipeline
name: default

steps:
- name: build
  image: alpine
  environment:
    USERNAME:
      from_secret: docker_username
    PASSWORD:
      from_secret: docker_password

2.2 通过CLI工具加密

Encrypted

$ drone -v
drone version 1.2.0
# drone encrypt [command options] <repo/name> <string>
$ drone encrypt octocat/hello-world username
hl3v+FODjduX0UpXBHgYzPzVTppQblg51CVgCbgDk4U=
kind: pipeline
name: default

steps:
- name: build
  image: alpine
  environment:
    USERNAME:
      from_secret: username

---
kind: secret
name: username
data: hl3v+FODjduX0UpXBHgYzPzVTppQblg51CVgCbgDk4U=

...

2.3 通过CLI工具添加到repo

# drone secret
# drone secret add [command options] [repo/name]
$ drone secret add --name usrname --data letitia letitia/albert_zh
$ drone secret rm --name usrname letitia/albert_zh

2.4 用于SSH Pipeline中的server配置

server:
  host:
    from_secret: host
  user:
    from_secret: username
  password:
    from_secret: password

2.5用于environment中的变量

steps:
- name: build
  commands:
  - docker login -u $USERNAME -p $PASSWORD
  - docker build -t hello-world .
  - docker push hello-world
  environment:
    PASSWORD:
      from_secret: password
    USERNAME:
      from_secret: username

3. docker-in-docker

Services/Docker (dind)

Build and then run an image

In the below example we demonstrate a pipeline that launches a Docker service container (Docker-in-Docker). The service container is run in privileged mode. For security reasons, only trusted repositories can enable privileged mode.

---
kind: pipeline
name: default

steps:
- name: test
  image: docker:dind
  volumes:
  - name: dockersock
    path: /var/run
  commands:
  - sleep 5 # give docker enough time to start
  - docker ps -a

services:
- name: docker
  image: docker:dind
  privileged: true
  volumes:
  - name: dockersock
    path: /var/run

volumes:
- name: dockersock
  temp: {}

需要注意的是:需要是trusted仓库(挂载绝对路径),可以在图形界面Settings中设置,如果没有这一选项的话,意味着在启动Drone时没有将当前登录用户设置为管理员,详见

使用Drone进行持续集成

4. 跳过CI构建

GitLab可以在git push --push-option=<push_option>通过选项跳过CI构建:

Push Options

对于Drone,在提交的commit message中如果包含 [CI SKIP] 字段,会跳过CI构建

[ci skip] / [skip ci] not working

Allow any case/seq to be used for “[CI SKIP]” #1134

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值