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
steps:
step-name:
type: git-clone
clone_dir: sub/folder/| Parameter | Description | Required |
|---|---|---|
| title | The display name of the step. | No |
| type | The type of the Microtica built-in step. Should always be git-clone for this type of step. | Yes |
| clone_dir | Path to where the source code should be cloned. Default: . Current working dir of the pipeline runtime environment. | No |
| ssh_key | Provide 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_submodules | Clone 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.
steps:
Clone:
type: git-clone
clone_dir: sub/folder
ListContent:
image: alpine:latest
commands:
- cd sub/folder
- ls -lIf 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:
cat ~/.ssh/id_rsa | base64Copy 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:
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
Steps
Build Microtica pipelines from steps. Use generic steps to run your own commands in any Docker image, or built-in steps for common CI/CD actions.
Docker Push
Build and push a Docker image to a remote registry with the docker-push step. Set the tag, Dockerfile path, build context, build arguments, and image scanning.