kind - 定義對象屬性的類別
目前有
type - 此屬性定義 Pipeline的類型
目前下列有六種
name - 此屬性定義 Pipeline的名稱
steps - 定義了一連串執行 Pipeline的步驟。 如果 Pipeline中的任何步驟失敗,將會立即退出
看完上述描述可以看下方的 exmaple yaml檔來比對
kind: pipeline
type: docker
name: backend
steps:
- name: golang test
image: golang:1.14
commands:
- go test
以下是我列出的練習題目及示範給各位
kind: pipeline
type: docker
name: backend
steps:
- name: practice
image: golang
commands:
- echo hello drone
kind: pipeline
type: docker
name: backend
steps:
- name: practice
image: golang
when:
branch:
- test
commands:
- go test
kind: pipeline
type: docker
name: backend
steps:
- name: practice
image: golang
when:
branch:
- test
- master
commands:
- go test
先建立一個 go.dockerfile 檔案
FROM golang
WORKDIR /ithome
ADD . /ithome
RUN cd /ithome && go build
CMD ["./ithome"]
.drone.yml
kind: pipeline
type: docker
name: backend
steps:
- name: test
image: docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build --no-cache --pull --force-rm -t rain/ithome:latest -f go.dockerfile .
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
kind: pipeline
type: docker
name: backend
steps:
- name: practice
when:
branch:
- master
image: docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build --no-cache --pull --force-rm -t rain/ithome:latest -f go.dockerfile .
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
kind: pipeline
type: docker
name: backend
steps:
- name: practice
image: docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build --no-cache --pull --force-rm -t rain/ithome:latest -f go.dockerfile .
trigger:
event:
- tag
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
明天會帶各位進入進階的練習唷~敬請期待!