【问题标题】:Fatal: Could not read password for 'https://OrganizationName@dev.azure.com': terminal prompts disabled致命:无法读取“https://OrganizationName@dev.azure.com”的密码:终端提示已禁用
【发布时间】:2021-10-21 19:57:04
【问题描述】:

在使用 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

在引用了一些 URL 后,我创建了个人访问令牌,并将推送命令修改为 git push https://PAT@dev.azure.com/OrganizationName,但仍然无法正常工作。

如果您找到此问题的解决方案,请告诉我。

【问题讨论】:

  • PAT 是您的解决方案,什么是“它也不起作用”?你得到了什么?
  • 得到错误为“致命:无法从重定向更新 url 基础:”
  • 你需要在url中追加团队项目和git repo

标签: git azure-devops azure-pipelines azure-powershell azure-pipelines-build-task


【解决方案1】:

正如您提到的,您需要使用 PAT,但以这种方式:

git push https://{PAT}@dev.azure.com/{organization}/{project}/_git/{repo-name}

另一种解决方案是在作业选项中“允许脚本访问 OAuth 令牌”:

在 git push 中使用 System.AccessToken:

git push https://$env:SYSTEM_ACCESSTOKEN@dev.azure.com/......

并授予构建用户推送权限(在 repo 设置中):

【讨论】:

  • 对于 .yaml 构建管道(目前 Azure Pipelines 的默认设置),设置 persistCredentials: true。请参阅Checkout 选项。
  • 今天 Azure 中没有contribute 权限,有什么可以替代的权限?
  • 我今天可以看到Contribute 权限..
【解决方案2】:

类似于Shayki's answer,但如果您没有运行 powershell 任务,请使用:

git push https://$(System.AccessToken)@dev.azure.com/......

我正在使用

  • 经典管道
  • onprem Windows 构建代理
    • 代理作业设置已启用允许脚本访问 OAuth 令牌
  • 命令行任务

【讨论】:

    【解决方案3】:

    删除 C:\program files\Git\dev\fd 然后重新安装 Microsoft git。

    【讨论】:

      猜你喜欢
      • 2020-08-02
      • 2023-02-07
      • 2021-03-09
      • 2020-05-04
      • 2021-11-04
      • 2019-08-29
      • 2017-08-12
      • 1970-01-01
      • 2014-01-22
      相关资源
      最近更新 更多