如何使用构建管道将文件提交到 azure git repo。
我正在从我的 azure ci 管道生成一些文件,我想将这些文件提交到我在 ci 管道中使用的同一个存储库中。
我添加了 azure CLI 任务并添加了一个内联命令来提交代码,但它给了我错误并且无法正常工作。
git add .
git commit -m "test commit"
git push -u origin Trunk
如何使用构建管道将文件提交到 azure git repo。
我正在从我的 azure ci 管道生成一些文件,我想将这些文件提交到我在 ci 管道中使用的同一个存储库中。
我添加了 azure CLI 任务并添加了一个内联命令来提交代码,但它给了我错误并且无法正常工作。
git add .
git commit -m "test commit"
git push -u origin Trunk
对于经典模式管道:
您可以启用该Allow scripts to access the OAuth token
选项。
并授予Project Collection Build Service Accounts的 Repo Contribute权限。
git命令:
git config --global user.email "email"
git config --global user.name "Kevin Lu"
git add .
git commit -m "My commit message"
git push origin master
对于 Yaml 管道:
您可以persistCredentials: true
在 YAML 示例中设置。
并授予Build Service的 Repo Contribute权限。
Yaml 示例:
steps:
- checkout: self
persistCredentials: true
- script: |
git config --global user.email "email"
git config --global user.name "Kevin Lu"
git add .
git commit -m "My commit message"
git push origin master
displayName: 'Command Line Script'
更详细的信息,你可以参考这张票。
请确保两者Project Collection Build Service Accounts
都<repo> Build Service (<org>)
在Allow
部分中Contribute
具有:
假设您已经完成了所有步骤在脚本中运行 Git 命令,您应该可以开始了。请注意,文档说您应该设置Project Collection Build Service
,但也需要设置Project Collection Build Service Accounts
。