logo
0
0
Login
feat: username和password非必填

git clone

介绍

将其他仓库clone到本地

原理

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

参数

user_name

  • type: string
  • 必填: 否

如设置,插件会执行 git config user.name

user_email

  • type: string
  • 必填: 否

如设置,插件会执行 git config user.email

dist

  • type: string
  • 必填: 否

将仓库 clone 到何处

git_url

  • type: string
  • 必填: 是

仓库地址, 如 https://xxx.com/xxx/xxx.git,不支持 ssh 地址

git_user

  • type: string
  • 必填: 否

登陆用的用户名,私有仓库必填

git_password

  • type: string
  • 必填: 否

登陆用的密码,私有仓库必填

depth

  • type: number
  • 必填: 否

clone 深度,如 1,如设置,插件会在 git clone 后追加 --depth {depth}

branch

  • type: string
  • 必填: 否

clone 分支,如 main,如设置,插件会在 git clone 后追加 --single-branch --branch {branch}

在 云原生构建 上使用

main: push: - stages: - name: git clone image: tencentcom/git-clone # 引用环境变量 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

云原生构建 可用 CNB_TOKEN_USER_NAMECNB_TOKEN 作 为 git_usergit_password 去 clone 云原生构建 的仓库。

# .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