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.
Property — clone
Required — No
Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)
Allowed parent properties — step 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
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
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
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.
Property — depth
Required — No
Data type — Integer or String
Allowed values — full
(for full depth) or any positive integer
Default value — 50
Allowed parent properties — clone
Example — using the depth option to only clone the last two commits for every step in the pipeline
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
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.
Property — enabled
Required — No
Data type — Boolean
Allowed values — true
or false
Default value — true
Allowed parent properties — clone
Example — using the clone enabled option to disable git clone for all steps
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
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.
Property — lfs
Required — No
Data type — Boolean
Allowed values — true
or false
Default value — false
Allowed parent properties — clone
Example — using lfs to download all LFS files in every step
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
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.
Property — skip-ssl-verify
Required — No
Data type — Boolean
Allowed values — true
or false
Default value — false
Allowed parent properties — clone (when clone is set in a step)
Example — using skip-ssl-verify to disable SSL verification on git clone operations
pipelines:
default:
- step:
runs-on:
- 'self.hosted'
clone:
skip-ssl-verify: true
script:
- echo "Use git with a self-signed certificate"
Was this helpful?