Git clone behavior
The Gitclone options section of thebitbucket-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 theclone option:
Clone
Theclone 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, theskip-ssl-verify option is available when theclone property is applied to an individualstep 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 thelfs,depth, andenabled properties.skip-ssl-verify is allowed when theclone element is in astep.
Example — using clone and enabled to only allow Git clone on selected steps
clone: enabled: falsepipelines: 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: 2pipelines: default: - step: script: - ls -R $BITBUCKET_CLONE_DIRExample — 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_DIRDepth
Defines the depth of Git clones for all pipelines or a pipeline step. Usefull for a full clone. If not specified, the default is the last 50 commits. For information on the Git clone depth option, visitGit 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: 2pipelines: default: - step: script: - ls $BITBUCKET_CLONE_DIRExample — 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_DIREnabled
Thecloneenabled option is used to disable the git clone operation which is run at the start of every step. Theenabled option can be used to disable Git clone operations for a singlestep, or for all steps.
Property —enabled
Required — No
Data type — Boolean
Allowed values —true orfalse
Default value —true
Allowed parent properties —clone
Example — using the clone enabled option to disable git clone for all steps
clone: enabled: falsepipelines: 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_DIRLFS
Thelfs options instructs git to download all LFS files for the repository during git clone operations. Whenlfs is set totrue as a global option, all LFS files will be downloaded at the start of every step. Whenlfs is set totrue 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 orfalse
Default value —false
Allowed parent properties —clone
Example — using LFS to download all LFS files in every step
clone: lfs: truepipelines: default: - step: name: Clone and download script: - echo "Clone and download my LFS files!"LFS (GIT only) - Enables the download of LFS files in your clone. If defaults to false if not specified. Note that the keyword is supported only for Git repositories.
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.zipSkip SSL verification
Only available forself-hosted pipeline runners.
Theskip-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 orfalse
Default value —false
Allowed parent properties —clone (whenclone is set in astep)
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?
- Bitbucket Pipelines configuration reference
- Global options
Git clone behavior
- Cache, service container, and export pipelines definitions
- Docker image options
- Pipeline start conditions