提交本地代码
提交时的 Commit Message
临时分支名
为了防止自动化提交过于随意而导致的风险,会先创建临时分支,提交变动,再推送到 origin ,而不是直接在对应分支上提交。
有些项目可能会对分支名有限制,这里可以指定分支名。
是否送到到当前分支,为 true 则忽略 branchName
如果在 push 流水线中,可能会引起流水线死循环
慎重选择
指定 git add 的目录、文件列表,通过 glob
模式匹配 git status --porcelain 得到的变更文件。
注意:新增了一个文件夹,如 dir1/dir2,不管里面多少文件,变更文件是 dir1/dir2/,
可用 dir1/dir2/** 匹配其文件夹或文件夹下所有文件。
若 pushCurrent 不为 true,则导出 branch 为 新建分支名。
test:
push:
- stages:
- name: set token
imports: https://xxx.com/token.yml # 从私有仓库引入 TOKEN
image: tencentcom/git-set-credential:latest
settings:
userName: ${USER_NAME}
userEmail: ${USER_EMAIL}
loginUserName: ${LOGIN_USER_NAME}
loginPassword: ${LOGIN_PASSWORD}
- name: update file
script: echo test > test.txt
- name: commit
image: tencentcom/git-commit:latest
settings:
add:
- test.txt
commitMessage: "commit by ci"
exports:
branch: COMMIT_BRANCH
- name: show branch
script: echo $COMMIT_BRANCH
docker run --rm \ -e TZ=Asia/Shanghai \ -e PLUGIN_COMMITMESSAGE="test: committed by ci" \ -e PLUGIN_ADDPATTERNS="test.txt" \ -v $(pwd):$(pwd) \ -w $(pwd) \ tencentcom/git-commit:latest