Version 0.9.0
Language EN

Cloning

The goal of this document is to give you enough technical specifics to configure or customize the default clone behavior. The default clone behavior is simple, by design, and may require additional pipeline steps in order to extend.

--depth

The default clone configuration does not set a depth. You can enforce a clone depth by declaring a clone block and adding the depth attribute:

kind: pipeline
name: default

clone:
  depth: 50

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

--tags

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:

kind: pipeline
name: default

clone:
  depth: 50

steps:
- name: fetch
  image: docker/git
  commands:
  - git fetch --tags

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

--recursive

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:

kind: pipeline
name: default

clone:
  depth: 50

steps:
- name: submodules
  image: docker/git
  commands:
  - git submodule update --recursive --remote

- name: build
  image: golang
  commands:
  - go build
  - 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:

kind: pipeline
name: default

clone:
  disable: true

steps:
- name: clone
  image: docker/git
  commands:
  - git clone https://github.com/octocat/hello-world.git
  - git checkout $DRONE_COMMIT

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

In the following we disable the default clone behavior, and delegate the clone logic to a custom plugin in our pipeline:

kind: pipeline
name: default

clone:
  disable: true

steps:
- name: clone
  image: janecitizen/cloner

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

On This Page:

Getting Help

Enterprise Support
Real-time chat support from the developers that wrote the code.
Mailing List
Search for information in the mailing list archives, or post a question.