Clone a remote repository to the local environment.
git clone https://{user}:{password}@{url}
If set, the plugin will execute git config user.name.
If set, the plugin will execute git config user.email.
The destination directory for the cloned repository.
The URL of the repository, e.g., https://xxx.com/xxx/xxx.git. SSH URLs are not supported.
The username for authentication. Required for private repositories.
The password for authentication. Required for private repositories.
Clone depth, e.g., 1. If set, the plugin will append --depth {depth} to the git clone command.
The branch to clone, e.g., main. If set, the plugin will append --single-branch --branch {branch} to the git clone command.
main:
push:
- stages:
- name: git clone
image: tencentcom/git-clone
# Reference environment variables
imports: https://xxx.com/git-clone.yml
settings:
user_name: xxx
user_email: xxx
git_url: https://xxx/xxx/demo1.git
git_user: $GIT_USER
git_password: $GIT_PASSWORD
dist: other_repos
- name: git commit
script:
- cd other_repos/demo1
- echo 1 > tmp.txt
- git add .
- git commit -m "test"
- git push
In Cloud Native Build, you can use CNB_TOKEN_USER_NAME and CNB_TOKEN as git_user and git_password respectively to clone repositories from Cloud Native Build.
# .cnb.yml
main:
push:
- stages:
- name: git clone
image: tencentcom/git-clone
settings:
user_name: xxx
user_email: xxx
git_url: https://xxx/xxx/demo1
git_user: $CNB_TOKEN_USER_NAME
git_password: $CNB_TOKEN
dist: other_repos