Git clone behavior

The Git clone options section of the bitbucket-pipelines.yml allows you to change the Git clone behavior in Bitbucket Pipelines, including disabling or selectively enabling Git clone operations (performed at the start of every step). Most of these settings can be applied globally or to individual steps.

Git clone options for pipelines

The following options can be configured using the clone option:

Clone

The clone property provides options for controlling how your repository is cloned by Bitbucket Pipelines during a build.

The following options are available for controlling the git clone behavior for the whole pipeline:

  • lfs — support for Git LFS.

  • depth — the depth of the Git clone.

  • enabled — allows the Git clone to be disabled.

Additionally, the skip-ssl-verify option is available when the clone property is applied to an individual step when the step is run on a self-hosted pipeline runner.

Propertyclone

Required — No

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiesstep or the YAML root (clone can be a top-level property)

Allowed child properties — Requires one or more of the lfs, depth, and enabled properties. skip-ssl-verify is allowed when the clone element is in a step.

Example — using clone and enabled to only allow Git clone on selected steps

1 2 3 4 5 6 7 8 9 10 11 12 13 clone: enabled: false pipelines: default: - step: script: - echo "No code cloned!" - step: clone: enabled: true script: - echo "Repo cloned in this step!"

Example — using clone to configure global git clone behavior for a pipeline

1 2 3 4 5 6 7 8 9 clone: lfs: true # See the lfs property documentation prior to enabling depth: 2 pipelines: default: - step: script: - ls -R $BITBUCKET_CLONE_DIR

Example — using clone to customize git clone behavior on a single step

1 2 3 4 5 6 7 8 9 10 11 12 pipelines: default: - step: runs-on: - self.hosted - linux clone: lfs: true # See the lfs property documentation prior to enabling depth: 2 skip-ssl-verify: true script: - ls -R $BITBUCKET_CLONE_DIR

Depth

Defines the depth of Git clones for all pipelines or a pipeline step. Use full for a full clone. If not specified, the default is the last 50 commits. For information on the Git clone depth option, visit Git Documentation — git clone.

Propertydepth

Required — No

Data type — Integer or String

Allowed valuesfull (for full depth) or any positive integer

Default value50

Allowed parent propertiesclone

Example — using the depth option to only clone the last two commits for every step in the pipeline

1 2 3 4 5 6 7 8 clone: depth: 2 pipelines: default: - step: script: - ls $BITBUCKET_CLONE_DIR

Example — using the depth option to only clone the last two commits for a single step

1 2 3 4 5 6 7 pipelines: default: - step: clone: depth: 2 script: - ls $BITBUCKET_CLONE_DIR

Enabled

The clone enabled option is used to disable the git clone operation which is run at the start of every step. The enabled option can be used to disable Git clone operations for a single step, or for all steps.

Propertyenabled

Required — No

Data type — Boolean

Allowed valuestrue or false

Default valuetrue

Allowed parent propertiesclone

Example — using the clone enabled option to disable git clone for all steps

1 2 3 4 5 6 7 8 clone: enabled: false pipelines: default: - step: script: - echo "No code cloned!"

Example — using the clone enabled option to disable git clone on a pipeline step

1 2 3 4 5 6 7 8 9 10 pipelines: default: - step: clone: enabled: false script: - ls -R $BITBUCKET_CLONE_DIR - step: script: - ls -R $BITBUCKET_CLONE_DIR

LFS

The lfs options instructs git to download all LFS files for the repository during git clone operations. When lfs is set to true as a global option, all LFS files will be downloaded at the start of every step. When lfs is set to true on an individual step, then all the LFS files will be downloaded for that step. We recommend using LFS on individual steps or to download only the required files for each step to reduce build times and resource usage.

Propertylfs

Required — No

Data type — Boolean

Allowed valuestrue or false

Default valuefalse

Allowed parent propertiesclone

Example — using lfs to download all LFS files in every step

1 2 3 4 5 6 7 8 9 clone: lfs: true pipelines: default: - step: name: Clone and download script: - echo "Clone and download my LFS files!"

Example — using lfs to selectively download LFS files

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 pipelines: default: - step: name: Clone with lfs on clone: lfs: true script: - ls -lh large-file.zip # 26M large-file.zip - step: name: Clone with lfs off clone: lfs: false script: - apt-get update && apt-get install -y git-lfs # Download only desired files - git lfs pull --include=large-file.zip - ls -lh large-file.zip # 26M large-file.zip

Skip SSL verification

Only available for self-hosted pipeline runners.

The skip-ssl-verify option disables SSL verification during git clone, allowing the use of self-signed certificates.

Propertyskip-ssl-verify

Required — No

Data type — Boolean

Allowed valuestrue or false

Default valuefalse

Allowed parent propertiesclone (when clone is set in a step)

Example — using skip-ssl-verify to disable SSL verification on git clone operations

1 2 3 4 5 6 7 8 9 pipelines: default: - step: runs-on: - 'self.hosted' clone: skip-ssl-verify: true script: - echo "Use git with a self-signed certificate"

Additional Help