クローニング
Droneは、パイプラインステップを実行する前に、リポジトリのクローンを自動的に作成します。特別な設定は必要ありません。ただし、場合によっては、デフォルトのクローン動作をカスタマイズ、オーバーライド、または無効にする必要があります。
--depthフラグ
デフォルトのクローン構成では、 --depth
フラグが使用されます。 clone
ブロックをdepth
属性を追加することで、クローンの深さを強制できます。
1 kind: pipeline
2 type: ssh
3 name: default
4
5 server:
6 host: 1.2.3.4
7 user: root
8 password:
9 from_secret: password
10
11 clone:
12 depth: 50
13
14 steps:
15 - name: build
16 commands:
17 - go build
18 - go test
--tagsフラグ
デフォルトのクローン構成では、 --tags
フラグは使用されません。タグをフェッチする場合は、パイプラインのステップとしてこれを処理する必要があります。例えば:
1 kind: pipeline
2 type: ssh
3 name: default
4
5 server:
6 host: 1.2.3.4
7 user: root
8 password:
9 from_secret: password
10
11 steps:
12 - name: fetch
13 commands:
14 - git fetch --tags
15
16 - name: build
17 commands:
18 - go build
19 - go test
--recursiveフラグ
デフォルトのクローン動作は--recursive
フラグを使用せず、サブモジュールをフェッチしません。サブモジュールをフェッチする場合は、パイプラインのステップとしてこれを処理する必要があります。例えば:
1 kind: pipeline
2 type: ssh
3 name: default
4
5 server:
6 host: 1.2.3.4
7 user: root
8 password:
9 from_secret: password
10
11 steps:
12 - name: submodules
13 commands:
14 - git submodule update --recursive --remote
15
16 - name: build
17 commands:
18 - go build
19 - go test
カスタムロジック
必要に応じて、デフォルトのクローン動作を無効にし、カスタムクローンロジックを実装できます。次の例では、パイプラインステップとしてカスタムクローンコマンドを実装します。
1 kind: pipeline
2 type: ssh
3 name: default
4
5 server:
6 host: 1.2.3.4
7 user: root
8 password:
9 from_secret: password
10
11 clone:
12 disable: true
13
14 steps:
15 - name: clone
16 commands:
17 - git clone https://github.com/octocat/hello-world.git .
18 - git checkout $DRONE_COMMIT
19
20 - name: build
21 commands:
22 - go build
23 - go test