MicroticaMicrotica

Git Clone

Clone a Git repository into your pipeline runtime with the git-clone step. Set a target directory, clone submodules, or authenticate with an SSH key.

Clone a Git repository into the pipeline runtime environment.

You provide the Git account and repository when you create a pipeline. The Git Clone step uses them automatically when the pipeline runs, obtaining temporary access credentials from the Git accounts connected in the Microtica portal.

Git credentials

Credentials for the specified Git repository will be automatically provided by Microtica.

Syntax

microtica.yaml
steps:
  step-name:
    type: git-clone
    clone_dir: sub/folder/
ParameterDescriptionRequired
titleThe display name of the step.No
typeThe type of the Microtica built-in step.
Should always be git-clone for this type of step.
Yes
clone_dirPath to where the source code should be cloned.

Default: .
Current working dir of the pipeline runtime environment.
No
ssh_keyProvide a private SSH key to be used when cloning the source code from Git repository.

The key should be provided in base64 format.
You can encode the private key in base64 format using the following command where id_rsa is your private key:
cat ~/.ssh/id_rsa | base64

Default: null
No
clone_submodulesClone all submodules recursively for a given Git repository.

Default: false
No

Clone into a subdirectory

By default, the source code is cloned into the current working dir of the pipeline runtime environment. To store the code in a different directory, use the clone_dir parameter.

microtica.yaml
steps:
  Clone:
    type: git-clone
    clone_dir: sub/folder
  ListContent:
    image: alpine:latest
    commands:
      - cd sub/folder
      - ls -l

If you navigate to sub/folder and run ls -l in the next step, you see the contents of the source code root dir.

Use an SSH key with Git

To access the Git repository with an SSH key, provide the key as a sensitive pipeline environment variable with the key ssh_key.

To encode the private key in base64 format, run the following command, where id_rsa is your private key:

Terminal
cat ~/.ssh/id_rsa | base64

Copy and paste the encoded key into a pipeline variable. You can find the environment variables in Resource/App settings under Git.

Security consideration

Please make sure that you enable Sensitive option for the SSH key environment variable. This way the value will be stored and processed in a secure storage instead of plain value.

To use an environment variable key other than ssh_key, set a step parameter that references the pipeline environment variable. Here is an example step specification:

microtica.yaml
steps:
  Clone:
    type: git-clone
    ssh_key: "{{MY_SSH_KEY_ENV_VAR}}"

Here, MY_SSH_KEY_ENV_VAR is the environment variable key defined in the Microtica pipeline.

Next steps

On this page