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 1 year has passed since last update.

Drone CLI 使い方

Last updated at Posted at 2021-07-01

めったにやらないのにメモらないから忘れる。今回こそメモる。

Ref
https://readme.drone.io/quickstart/cli/

install

brew install drone-cli

local 実行

簡単. .drone.yml があれば引数不要

cd repos/project
drone exec

secret

.drone.yml で from_secret しておく。
空でもいいのでenvが欲しい場合、commandsでexportするのがワタシ的には楽な最近(ES_PWのところ)

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

steps:
    - name: Unit Tests
      image: python:3.9
      environment:
        DB_URI:
          from_secret: DB_URI
      commands:
        - pip install -r requirements.txt
        - export ES_PW=
        - make test

drone exec にわたす secret を作っておく

.drone.secret
DB_URI=mysql+pymysql://...

secretを指定して実行

drone exec --secret-file=.drone.secret

この option は ↓ に書いてあったけど、気づかないって・・

https://readme.drone.io/cli/drone-exec/

step指定

UnitTestsという名前のstepを実施。

$ drone exec --include "UnitTests"
  • depends on してる場合、その前のstepも実行される。

あるあるerror

その1

$ drone exec
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

docker 起動しましょう

その2

$ drone exec
何も出ない
  1. docker pullに時間かかってます。imageでかくない?
  2. ymlがなんかおかしいみたいです。echoするだけの .drone.yml にして試してみましょう。
kind: pipeline
type: docker
name: default
   
steps:
- name: test
  image: alpine
  commands:
  - echo hello
  - echo world

https://readme.drone.io/quickstart/cli/

その3

[clone:1] fatal: destination path '.' already exists and is not an empty directory.
clone : exit code 128

cloneが走ろうとしている。.drone.ymlの中をシンプルにして、cloneしてるstepを除外しよう。depends onも全部消そう。

その4

$ drone exec
proto: duplicate proto type registered: PluginSpec
proto: duplicate proto type registered: PluginPrivilege
No stage specified, assuming 'default'
Stage '' not found in build file : resource not found

pipelineの名前を指定するか、 default にしましょう

---
kind: pipeline
type: docker
name: default     <---

その5 : Rancher Desktop

docker daemonに繋がらない

$ sudo drone exec
2024/02/06 10:34:14 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Rancher Desktop > preferences > application > Administrative Access の check をつけたら動きました

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?