git 将 TeamCity 与 BitBucket 结合使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19730454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:18:07  来源:igfitidea点击:

Using TeamCity with BitBucket

gitteamcitybitbucket

提问by Phil Sandler

I am currently setting up a TeamCity build server that will pull source code from our git repositories, which are hosting on Bitbucket. I am doing this for a repositories that are setup as part of a team on Bitbucket (not my personal account).

我目前正在设置一个 TeamCity 构建服务器,它将从我们托管在 Bitbucket 上的 git 存储库中提取源代码。我正在为作为 Bitbucket 团队的一部分(不是我的个人帐户)设置的存储库执行此操作。

What I am running into is that the URL paths seem to be custom for each user. For example, my paths look like:

我遇到的是每个用户的 URL 路径似乎都是自定义的。例如,我的路径如下所示:

https://[email protected]/TeamName/RepoName.git

If I were to leave the company, this would be a nightmare to update for 40+ builds.

如果我要离开公司,更新 40 多个版本将是一场噩梦。

I have considered creating a service account on bitbucket for the build server to use, but this will take up one of our users (we only have a 10-user license).

我曾考虑在 bitbucket 上创建一个服务帐户以供构建服务器使用,但这将占用我们的一个用户(我们只有 10 个用户的许可证)。

Is creating a separate account the recommended approach, or are there better options?

创建一个单独的帐户是推荐的方法,还是有更好的选择?

回答by Antao Almada

You should use a deployment key. It gives read-only access to both private and public repositories. Check the documentation at https://confluence.atlassian.com/display/BITBUCKET/Use+deployment+keys

您应该使用部署密钥。它提供对私有和公共存储库的只读访问权限。在https://confluence.atlassian.com/display/BITBUCKET/Use+deployment+keys查看文档

回答by Alex T.

Creating a separate account is an acceptable approach if you want to do more on TeamCity side than just pull code for builds (for example, labeling builds, etc.). If you use a separate account for your TeamCity you could use both user/password authentication or SSH key authentication.

如果您想在 TeamCity 方面做更多事情而不仅仅是为构建提取代码(例如,标记构建等),则创建单独的帐户是一种可以接受的方法。如果您为 TeamCity 使用单独的帐户,则可以同时使用用户/密码身份验证或 SSH 密钥身份验证。

In the repository URL path you can safely remove the "MyUserName@" part which would make all the repository URLs uniformed regardless of how you access them. Moreover you could parameterize the user name and password in the TeamCity configuration so they can be overridden when someone wants to run a custom build.

在存储库 URL 路径中,您可以安全地删除“MyUserName@”部分,这将使所有存储库 URL 统一,无论您如何访问它们。此外,您可以在 TeamCity 配置中参数化用户名和密码,以便在有人想要运行自定义构建时覆盖它们。

As far as I am concerned there is no "recommended approach" for TeamCity since TeamCity is Git flavor agnostic. But Atlassian suggests to use SSH key when integrating with Bamboo. I am using a dedicated account for as long as I have one in the license since it makes management and debugging much easier.

就我而言,TeamCity 没有“推荐的方法”,因为 TeamCity 与 Git 风格无关。但是 Atlassian 建议在与 Bamboo 集成时使用 SSH 密钥。只要我在许可证中有一个专用帐户,我就会使用一个专用帐户,因为它使管理和调试变得更加容易。