VKD*_*VKD 14 git azure-powershell azure-devops azure-pipelines-build-task azure-pipelines
使用 Azure Pipelines PowerShell 任务构建时,我试图将develop分支合并到分支master。
但是在执行命令时git push,我收到此错误:
致命:无法读取“ https://OrganizationName@dev.azure.com ”的密码:终端提示已禁用
代码存储库是“Azure Repos Git”。
git checkout -b master
git config --global user.email "xxxxxxx@xxxx.xxx"
git config --global user.name "xxxxx"
git merge origin/develop
git push origin master
Run Code Online (Sandbox Code Playgroud)
在引用了一些 URL 之后,我创建了个人访问令牌,并将推送命令修改为git push https://PAT@dev.azure.com/OrganizationName,但它仍然无法正常工作。
如果您找到解决此问题的方法,请告诉我。
Sha*_*zyk 14
正如您所提到的,您需要使用 PAT 但以这种方式:
git push https://{PAT}@dev.azure.com/{organization}/{project}/_git/{repo-name}
Run Code Online (Sandbox Code Playgroud)
另一种解决方案是在作业选项中“允许脚本访问 OAuth 令牌”:
在 git push 中使用 System.AccessToken:
git push https://$env:SYSTEM_ACCESSTOKEN@dev.azure.com/......
Run Code Online (Sandbox Code Playgroud)
并向构建用户授予推送权限(在 repo 设置中):
添加结账作为第一步:
steps:
- checkout: self
persistCredentials: true
Run Code Online (Sandbox Code Playgroud)
确保你设置了 git 配置
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Run Code Online (Sandbox Code Playgroud)
确保向构建服务授予版本控制权限。
Project Collection Build Service ({your organization}):您现在应该能够使用 git 命令,而无需手动将访问令牌附加到任何 git 命令。
| 归档时间: |
|
| 查看次数: |
15463 次 |
| 最近记录: |