Skip to main content

Clone a subdirectory

If you want to clone a subdirectory instead of your entire Git repo, you can disable the pipeline's default codebase and then run your git commands in a Run step.

You can also use this pattern if you need to use specific git clone arguments to clone your codebase.

Disable Clone Codebase

You must disable Clone Codebase so that you can clone the repo according to your specifications. If Clone Codebase is enabled, then the build clones the pipeline's default codebase automatically.

In the Visual editor, you can disable Clone Codebase in the Build stage's Overview tab.

In the YAML editor, set cloneCodebase to false in the stage.spec.

    - stage:
name: build
identifier: build
description: ""
type: CI
cloneCodebase: false

Add a Run step to clone the codebase

Add a Run step containing your desired git commands, such as git sparse-checkout to clone a subdirectory instead of an entire repo.

              - step:
type: Run
identifier: clone
name: clone
shell: Sh
command: |-
git sparse-checkout ...