跨 Mercurial 子存​​储库进行身份验证

发布于 2024-11-16 13:39:37 字数 762 浏览 2 评论 0原文

我有一个 Mercurial 存储库,它使用子存储库功能(如 .hgsub 文件中定义)引入依赖项,但我很难在 TeamCity 中使其正常工作。

我启用了 Mercurial_keyring 扩展以保存凭据(因此,当 TeamCity 提供根存储库的身份验证详细信息时,它会记住子存储库的这些详细信息)。我也在 Mercurial.ini 中添加了一个 [auth] 部分:

[auth]
bitbucket.schemes = https
bitbucket.prefix = https://bitbucket.org/xyz
bitbucket.username = xyz

如果我从命令行运行 hg clone,系统会提示我输入一次密码,一切都很好。但是通过 TeamCity 运行时的初始结帐失败,并显示“

VCS root: mercurial: https://bitbucket.org/xyz/projectA {instance id=23, parent id=1}, due to error: 'cmd /c hg update -C -r 4a08f587bb1f' command failed. stderr: abort: http authorization required  stdout: pulling subrepo src\Common.Library from https://bitbucket.org/xyz/common.library

我缺少什么,或者我是否以完全错误的方式处理此问题?”非常感谢!

I've got a mercurial repository, which pulls in dependencies using the subrepository functionality (as defined in the .hgsub file), but I'm struggling to get this working in TeamCity.

I've enabled the mercurial_keyring extension in order to save credentials (so when TeamCity provides authentication details for the root repository, it remembers them for the subrepositories). I've added an [auth] section to mercurial.ini too:

[auth]
bitbucket.schemes = https
bitbucket.prefix = https://bitbucket.org/xyz
bitbucket.username = xyz

If I run hg clone from the command line, I get prompted for a password once, and all is good. But the initial checkout when run via TeamCity fails with

VCS root: mercurial: https://bitbucket.org/xyz/projectA {instance id=23, parent id=1}, due to error: 'cmd /c hg update -C -r 4a08f587bb1f' command failed. stderr: abort: http authorization required  stdout: pulling subrepo src\Common.Library from https://bitbucket.org/xyz/common.library

What am I missing, or am I going about this in completely the wrong way? Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

扎心 2024-11-23 13:39:37

似乎直接从 TeamCity 传递凭据不适用于 Mercurial_keyring,但如果我在 Mercurial.ini 文件中以明文形式指定用户名和密码(确保可以在运行 TeamCity 构建代理的帐户下访问它),那么这有效。

如果在用户路径下不起作用,则可以将mercurial.ini 文件放置在\mercurial.ini 下。

不理想,但一种解决方案......如果其他人找到更好的解决方案,请告诉我。

It seems that passing in credentials directly from TeamCity doesn't work with mercurial_keyring, but if I specify both username and password in plaintext in the mercurial.ini file (making sure it's accessible under the account the TeamCity build agent is running under), then this works.

The mercurial.ini file can be placed under <mercurial install path>\mercurial.ini if it does not work under user path.

Not ideal, but a solution... if anyone else finds a better one, please let me know.

∞琼窗梦回ˉ 2024-11-23 13:39:37

可能它在 TeamCity 的最新版本中得到了修复,但以下方法对我有用:

  1. 配置构建代理服务在域帐户下运行
    访问 HG 存储库(根存储库和子存储库)
  2. 在构建代理上启用 mercurial_keyring 并添加 [auth] 部分
    到 Mercurial config
  3. 尝试手动克隆存储库,输入
    密码。无需等到整个存储库被克隆——它可以
    当显示“请求所有更改”消息时终止。
  4. 玩得开心——现在服务将使用密钥环。

May be it got fixed in last versions of TeamCity, but the following works for me:

  1. Configure build agent service to run under domain account with
    access to HG repositories (both root and subrepos)
  2. Enable mercurial_keyring on build agent and add [auth] section
    to mercurial config
  3. Try to clone repository manually, enter
    password. No need to wait until the whole repo is cloned -- it could
    be terminated when "requesting all changes" message is shown.
  4. Have fun -- now service will use keyring.
忆伤 2024-11-23 13:39:37

可能根本不应该将 [auth] 部分添加到 TC 代理的 mercurial.ini 中。 Team City 使用 --config auth... 选项来 hg。我还建议不要使用 Mercurial_keyring,而是在 VCS 根目录中设置用户名和密码 - 这既安全又在不同 TC 代理之间共享。

不确定 bitbucket,但在其他情况下使用 https 方案可能需要证书配置。这可以在 mercurial.ini 中配置:

[web]
cacerts =

[hostfingerprints]
# hides mercurial warnings
domain-name = ab:cd:...:01

最后一部分:根据 .hgsub,可能需要在 Team City 版本控制中使用 VCS 签出模式“自动在代理上”设置。

Probably the [auth] section shouldn't be added at all to the mercurial.ini for the TC agent. Team City uses --config auth... options to hg. I would also recommend not to use the mercurial_keyring but to set the username and password in VCS root - this is both secure and shared between different TC agents.

Not sure about the bitbucket, but in other cases usage of https scheme can require certificates configuration. This can be configured in mercurial.ini:

[web]
cacerts =

[hostfingerprints]
# hides mercurial warnings
domain-name = ab:cd:...:01

And last part: depending on .hgsub it might be needed to use VCS checkout mode "Automatically on agent" in Team City Version Control Settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文