drone 的几个核心组件

1. clone

这个是内置的,实际上就行进行代码clone的

参考配置,同时我们可以使用自定义的插件

clone:
+  git:
+    image: plugins/git

pipeline:
  build:
    image: golang
    commands:
      - go build
      - go test
      
2. workspace
字面意思是工作空间,drone 的pipeline 过程中是共享的

参考配置 ,实际上就是指定我们项目代码的位置,以及目录结构

+workspace:
+  base: /go
+  path: src/github.com/octocat/hello-world

pipeline:
  build:
    image: golang:latest
    commands:
      - go get
      - go test
3. pipelins
构建的任务

参考配置

pipeline:
  backend:
    image: golang
    commands:
      - go build
      - go test
  frontend:
    image: node
    commands:
      - npm install
      - npm run test
      - npm run build
      
4. webhook
实际上就是我们的项目构建出发的条件

实际的一些条件参考
http://docs.drone.io/pipeline-conditions/
5. service 
我们项目运行依赖的一些服务(redis, 数据库 。。。)

参考配置, 访问方式类似docker-compose 

pipeline:
  build:
    image: golang
    commands:
      - go build
      - go test

services:
  database:
    image: mysql

  cache:
    image: redis
6. plugins
实际上drone 的每个任务都是使用容器插件构建的

参考

pipeline:
  build:
    image: golang
    commands:
      - go build
      - go test

  publish:
    image: plugins/docker
    repo: foo/bar
    tags: latest

  notify:
    image: plugins/slack
    channel: dev 
    
7. promoting(提升,实际上就是开发中环境的转变)
参考

pipeline:
  build:
    image: golang
    commands:
      - go build
      - go test

  publish:
    image: plugins/docker
    registry: registry.heroku.com
    repo: registry.heroku.com/my-staging-app/web
    when:
+     event: deployment
+     environment: staging

  publish_to_prod:
    image: plugins/docker
    registry: registry.heroku.com
    repo: registry.heroku.com/my-production-app/web
    when:
+     event: deployment
+     environment: production
8. Matrix Builds
实际上就是我们的一些构建环境参数 比如 golang 的不同运行时环境

参考配置

pipeline:
  build:
    image: golang:${GO_VERSION}
    commands:
      - go get
      - go build
      - go test

services:
  database:
    image: ${DATABASE}

matrix:
  GO_VERSION:
    - 1.4
    - 1.3
  DATABASE:
    - mysql:5.5
    - mysql:6.5
    - mariadb:10.1
9. 参考资料
http://docs.drone.io/hooks/
http://docs.drone.io/workspace/
http://docs.drone.io/cloning/
http://docs.drone.io/pipelines/
http://docs.drone.io/services/
http://docs.drone.io/using-plugins/
http://docs.drone.io/promoting-builds/
http://docs.drone.io/matrix-builds/

猜你喜欢

转载自www.cnblogs.com/rongfengliang/p/8982143.html