0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Drone で CI をおこなう

0
Last updated at Posted at 2021-04-23
  • Drone CI Server がセットアップ済であること。

準備

CLI をインストール

ローカルでの実行確認や Drone サーバーの API を叩くためのコマンド Drone CLI をインストールしておく。

macOS の場合)

$ brew tap drone/drone
$ brew install drone

サーバーの API を実行する場合、サーバーの URL と API トークンを環境変数に設定しておく。

$ export DRONE_SERVER=https://drone.example.jp
$ export DRONE_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

設定するトークンは Drone Server の画面にログインして画面右上の User settings から確認することができる。

リポジトリに対し、CI を有効にする

  1. Drone Server にログインする。
  2. リポジトリ一覧から対象を選択し、"ACTIVATE REPOSITORY"
    これにより、GitHub のリポジトリに Drone への Webhook 設定が追加される。この設定は GitHub リポジトリの Settings > Hooks から確認できる。
  3. "Project settings" の "Trusted" をチェックして "SAVE" ★この設定は Drone 管理者のみ設定可
    (これを有効にしないと一部の機能が使用できない。)

CI の設定

リポジトリのルートディレクトリに .drone.yml を作成してコミットする。

設定方法は Drone CI 基本設定 (.drone.yml) を参照。

ローカルでの実行確認

.drone.yml のあるディレクトリで以下のコマンドを実行する。(要 Docker Engine)

$ drone exec --trusted

Secrets を使っている場合、サーバーでないと復号できないため、ローカルに secret を (name)=(value) 形式で記述したテキストファイルを用意して指定する。

$ drone exec --trusted --secret-file=secrets.txt
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?