logo
1
0
WeChat Login

git clone

Introduction

Clone a remote repository to the local environment.

Principle

git clone https://{user}:{password}@{url}

Parameters

user_name

  • Type: string
  • Required: No

If set, the plugin will execute git config user.name.

user_email

  • Type: string
  • Required: No

If set, the plugin will execute git config user.email.

dist

  • Type: string
  • Required: No

The destination directory for the cloned repository.

git_url

  • Type: string
  • Required: Yes

The URL of the repository, e.g., https://xxx.com/xxx/xxx.git. SSH URLs are not supported.

git_user

  • Type: string
  • Required: No

The username for authentication. Required for private repositories.

git_password

  • Type: string
  • Required: No

The password for authentication. Required for private repositories.

depth

  • Type: number
  • Required: No

Clone depth, e.g., 1. If set, the plugin will append --depth {depth} to the git clone command.

branch

  • Type: string
  • Required: No

The branch to clone, e.g., main. If set, the plugin will append --single-branch --branch {branch} to the git clone command.

Usage on Cloud Native Build

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

About

git-clone

384.00 KiB
1 forks0 stars1 branches0 TagREADMEMIT license
Language
Shell73.9%
Dockerfile26.1%