LoginSignup
15
7

More than 5 years have passed since last update.

この記事は リクルートライフスタイル Advent Calendar 2018 の3日目の記事です。

はじめに

新規サービスの開発を行なっている @akechi です。
現在行なっているサービスの開発では、CI/CDツールにDroneを採用しています。
先月 1.0 Release Candidateがアナウンスされたので、どういったバージョンアップなのか追ってみました。

アップグレード時の注意事項

0.8から1.0への自動アップグレードはできません。
データベースに互換性のない変更があるため、アップグレードにはマイグレーションユーティリティが必要になります。
このユーティリティは11月16日までに用意するよという記述がドキュメントにありますが、まだないようです。

注目機能

YAMLフォーマットの大幅な機能強化

パイプラインのシンタックスは、1.0で大きく変わっています。
新しいシンタックスは、Kubernetesにインスパイアーされたものになっています。
Droneコミュニティの大部分がKubernetesをすでに採用しており、よく知られていることが理由みたいです。(わたしもその1人です)

古いフォーマット

.drone.yml
pipeline:
  build:
    image: golang
    commands:
    - go build
    - go test

services:
  redis:
    image: redis:latest

新しいフォーマット

.drone.yml
kind: pipeline
name: default

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

services:
- name: redis
  image: redis:latest

Multi-Machineパイプライン

ビルド時間を減らすために、複数のマシーンにビルドタスクを分散したい時に便利な機能です。
Multi-Machineパイプラインは、複数のYAMLドキュメントで設定します。
下記は2つの並列パイプラインを実行する例です。
ビルドステータスは、両方のパイプラインの結果で決まります。

.drone.yml
kind: pipeline
name: frontend

steps:
- name: build
  image: node
  commands:
  - npm install
  - npm test

---
kind: pipeline
name: backend

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

services:
- name: redis
  image: redis

Multi-Platformパイプライン

複数のOSやアーキテクチャでビルドやテストが必要な時に便利な機能です。
1つのパイプラインはLinux/ARMで実行されて、もう1つのパイプラインはLinux/AMD64で実行される例です。

.drone.yml
kind: pipeline
name: amd

platform:
  os: linux
  arch: amd64

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

---
kind: pipeline
name: arm64

platform:
  os: linux
  arch: arm64

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

署名付きYAMLファイル

信頼性を検証したり勝手に書き換えられることを防ぐために、YAMLファイルに署名することができます。
これはパブリックリポジトリで承認されていない変更を防ぐために特に便利な機能です。
もしユーザが変更して署名の検証に失敗すると、パイプラインは承認されるまでペンディングになります。
署名はYAMLファイルにsignatureリソースとして記述します。

.drone.yml
---
kind: pipeline
name: default

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

---
kind: signature
hmac: F10E2821BBBEA527EA02200352313BC059445190

Jsonnetによる設定

Jsonnetファイルで動的にYAMLファイルを生成する機能です。
例えば、Rubyの複数バージョンでテストを実行したい時に使えます。

.drone.yml
---
kind: pipeline
name: ruby-2-4

steps:
- name: test
  image: ruby:2.4
  commands:
  - bundle install --jobs=3 --retry=3
  - rake

---
kind: pipeline
name: ruby-2-3

steps:
- name: test
  image: ruby:2.3
  commands:
  - bundle install --jobs=3 --retry=3
  - rake

.jsonnetで書くと以下のようになります。

local Pipeline(name, image) = {
  kind: "pipeline",
  name: name,
  steps: [
    {
      name: "test",
      image: image,
      commands: [
        "bundle install --jobs=3 --retry=3",
        "rake"
      ]
    }
  ]
};

[
  Pipeline("ruby23", "ruby:2.3"),
  Pipeline("ruby24", "ruby:2.4"),
]

ネイティブサポート

エージェントを複数のOSとアーキテクチャにインストールできます。

  • Linux AMD64
  • Linux ARM
  • Linux ARM64
  • Windows 1803

ユーザインターフェースの改装

drone_1_screenshot.png

その他

  • cronジョブによるスケジューリング
  • drone fmtコマンド
  • Matrix の非推奨

まとめ

Drone 1.0 Release Candidateの機能を見てきました。
バージョンが1.0になったことで、今まで欲しいなと思っていた機能が着実に追加されてきています。
現在は0.8を使っているので、GAになったら本格的にアップグレードしたいなと思っています。

15
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
7