跨 Mercurial 子存储库进行身份验证
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
似乎直接从 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.
可能它在 TeamCity 的最新版本中得到了修复,但以下方法对我有用:
访问 HG 存储库(根存储库和子存储库)
mercurial_keyring
并添加[auth]
部分到 Mercurial config
密码。无需等到整个存储库被克隆——它可以
当显示“请求所有更改”消息时终止。
May be it got fixed in last versions of TeamCity, but the following works for me:
access to HG repositories (both root and subrepos)
mercurial_keyring
on build agent and add[auth]
sectionto mercurial config
password. No need to wait until the whole repo is cloned -- it could
be terminated when "requesting all changes" message is shown.
可能根本不应该将
[auth]
部分添加到 TC 代理的mercurial.ini
中。 Team City 使用--config auth...
选项来hg
。我还建议不要使用 Mercurial_keyring,而是在 VCS 根目录中设置用户名和密码 - 这既安全又在不同 TC 代理之间共享。不确定 bitbucket,但在其他情况下使用
https
方案可能需要证书配置。这可以在mercurial.ini
中配置:最后一部分:根据
.hgsub
,可能需要在 Team City 版本控制中使用 VCS 签出模式“自动在代理上”设置。Probably the
[auth]
section shouldn't be added at all to themercurial.ini
for the TC agent. Team City uses--config auth...
options tohg
. I would also recommend not to use themercurial_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 inmercurial.ini
:And last part: depending on
.hgsub
it might be needed to use VCS checkout mode "Automatically on agent" in Team City Version Control Settings.