Cloning
Drone automatically clones your repository before executing your pipeline steps. No special configuration is required. In some cases, however, you may need to customize, override or disable the default clone behavior.
The --depth flag
The default clone configuration does use the --depth
flag. You can enforce a clone depth by declaring a clone
block and adding the depth
attribute:
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
The --tags flag
The default clone configuration does not use the --tags
flag. If you would like to fetch tags you should handle this as a step in your pipeline. For example:
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
The --recursive flag
The default clone behavior does not use the --recursive
flag and does not fetch submodules. If you would like to fetch submodules you should handle this as a step in your pipeline. For example:
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
Custom Logic
The default clone behavior can be disabled and custom clone logic implemented, when necessary. In the following example we implement custom clone commands as a pipeline step:
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