简体   繁体   English

TeamCity:如何将未版本控制的配置文件放入已签出的存储库中?

[英]TeamCity: How to put unversioned configuration files in a checked-out repository?

I'm using a Git repository to version control my application. 我正在使用Git存储库来控制我的应用程序。 My project structure is such that I'm using config files that are localized to each environment the app is running in. These local config files contain things such as SQL connection strings and other info that is pertinent to each environment (each environment has its own SQL Server database, including the test environment in Teamcity). 我的项目结构是这样的,我正在使用本地化到运行应用程序的每个环境的配置文件。这些本地配置文件包含诸如SQL连接字符串之类的内容以及与每个环境相关的其他信息(每个环境都有自己的环境) SQL Server数据库,包括Teamcity中的测试环境)。 These files are not part of the repository, but are created newly when a new environment is created. 这些文件不是存储库的一部分,但是在创建新环境时会新创建。 In this paradigm, TeamCity is yet another environment and I have created a config file for TeamCity to use for building and running NUnit tests for my application. 在这个范例中,TeamCity是另一个环境,我为TeamCity创建了一个配置文件,用于为我的应用程序构建和运行NUnit测试。

My question is: How can I copy this file that is NOT under source control to the folder in which TeamCity checks out the repository? 我的问题是: 如何将不受源代码管理的文件复制到TeamCity检出存储库的文件夹中? And how can I do this before TeamCity starts building my application? 在TeamCity开始构建我的应用程序之前,我该如何做到这一点? I'm sure this is possible as I've read here that "Machine-specific settings (like configuring SSL communications, etc.) should be configured on each machine using agent-side checkout." 我确信这是可行的,因为我在这里读到“应该使用代理端签出在每台机器上配置特定于机器的设置(如配置SSL通信等)。” How exactly do I go about doing this? 我该怎么做呢? I could not find a straightforward answer from the documentation. 我无法从文档中找到直截了当的答案。

I read this thread that mentions the possibility of using multiple roots, which means it will pull the public sources from a public repository and private sources from a private repository with restricted access, and the access would only be given to TeamCity. 我读到了这个线程 ,它提到了使用多个根的可能性,这意味着它将从公共存储库中获取公共源,并从具有受限访问权限的私有存储库中获取私有源,并且只能访问TeamCity。 This is a decent solution and I can see how this could be easier to maintain than having a batch file or something copying the private/local files every time a build is run, but for some reason I don't feel comfortable putting passwords etc. in a repository. 这是一个不错的解决方案,我可以看到,这比每次运行构建时批处理文件或复制私有/本地文件更容易维护,但由于某种原因,我觉得放置密码等感觉不太舒服。在存储库中。 I'm not sure why I have this bias (it just seems like it could be vulnerable) and so if anyone has any experience with either or these solutions, I'd love to hear about them. 我不确定为什么我会有这种偏见(看起来它似乎很脆弱)所以如果有人对这两种解决方案有任何经验,我很乐意听到它们。 I'd also like to hear opinions on storing sensitive information under a password-protected repository. 我还想听听有关在受密码保护的存储库下存储敏感信息的意见。 Is this a safe practice? 这是安全的做法吗?

Thanks to anyone who can help out. 感谢任何可以提供帮助的人。

PS: I've looked at the Edit VCS Root page and the "Custom clone directory on server" setting, but I still don't know how to copy a file to that directory. PS:我查看了Edit VCS Root页面和“服务器上的自定义克隆目录”设置,但我仍然不知道如何将文件复制到该目录。 Does the working directory for TeamCity change or does it stay the same? TeamCity的工作目录是更改还是保持不变?

I don't like to put passwords in version control either, especially not externally hosted version control like Github. 我不喜欢将密码放在版本控制中,尤其不是像Github那样的外部托管版本控制。

I just put config files somewhere on the build machine outside of TeamCity and put a Command Line step in the build that copies them in to place before they're needed. 我只是将配置文件放在TeamCity之外的构建机器上的某个位置,并在构建中放置一个命令行步骤,在需要之前将它们复制到位。 Generally, 通常,

  • set "Command executable" to your copy program 将“命令可执行文件”设置为您的复制程序
  • set "Command parameters" to the source file(s) and target directory. 将“命令参数”设置为源文件和目标目录。

You don't need to worry about where the TeamCity work directory is, since the Command Line step's current directory will be your build directory and you can use a relative path as the target. 您无需担心TeamCity工作目录的位置,因为命令行步骤的当前目录将是您的构建目录,您可以使用相对路径作为目标。

I won't try to give specific examples because I use a different stack than you, but I think the same principle should work. 我不会尝试给出具体的例子,因为我使用的堆栈与你不同,但我认为同样的原则应该有效。

I ended up going the route of having a second private repository to store configuration files after examining the security aspects of having a public-facing privately-accessible repository that has sensitive information. 在检查了具有敏感信息的面向公众的可私有访问的存储库的安全性方面之后,我最终选择了第二个私有存储库来存储配置文件。 This technique is described here . 这里描述这种技术。

However, that link doesn't address a major issue with using multiple VCS roots - unless the checkout rules are modified, Teamcity copies the first VCS files to the checkout directory, deletes all the files, then copies the second VCS files to the same directory. 但是,该链接不能解决使用多个VCS根目录的主要问题 - 除非修改结帐规则,Teamcity会将第一个VCS文件复制到结帐目录,删除所有文件,然后将第二个VCS文件复制到同一目录。 I have no idea why this behavior was chosen as the default. 我不知道为什么选择此行为作为默认行为。 This obviously fails the build because the original code files are no longer there. 这显然无法构建,因为原始代码文件不再存在。

The solution is described here . 这里描述解决方案。 Basically I had to setup the checkout rules to move the files copied from the first VCS root to a subfolder, and then have checkout rules on the second VCS root to move the config files to the correct location within that subfolder. 基本上我必须设置结帐规则以将从第一个VCS根目录复制的文件移动到子文件夹,然后在第二个VCS根目录上具有结帐规则,以将配置文件移动到该子文件夹中的正确位置。

Now to the core issue: security implications of storing sensitive information in a public-facing privately-accessible repository. 现在讨论核心问题:将敏感信息存储在面向公众的私人可访问存储库中的安全隐患。 The important adjective here is public-facing. 这里重要的形容词是面向公众的。 My basic requirement for security in this scenario is that the repository should have as much security as a Windows folder that is secured using the Security tab. 我在这种情况下对安全性的基本要求是,存储库应具有与使用“安全”选项卡保护的Windows文件夹一样多的安全性。 The argument I use to justify that it is even more secure as a private Git repository is that is uses either HTTP or SSH security, which one could argue is just as strong, if not stronger, than Windows folder security since these are more exposed than Windows folders. 我用来证明它作为私有Git存储库更加安全的论据是使用HTTP或SSH安全性,人们可能认为它与Windows文件夹安全性一样强,如果不强,因为它们比Windows文件夹。 Since this is just going to be storing the login info for the test environment, I'm not too worried about it. 由于这只是存储测试环境的登录信息,所以我并不担心。 All sensitive info for my production environment will be handled manually. 我的生产环境的所有敏感信息都将手动处理。 But I'm open to opinions on this topic. 但我对这个话题持开放态度。 Hope this solution helps other people. 希望这个解决方案有助于其他人 Please feel free to comment/ask questions. 请随时评论/提问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使签出的分支成为主分支 - How to make checked-out branch to become master git从已签出的存储到分支 - git from checked-out stash to branch 使用git进行Web部署-如何仅在检出的实时站点中拥有大型二进制文件,而不是git repo中的blob - Web deployment with git - how to have large binaries only in checked-out live site, and not as blobs in git repo 为什么Git允许推送到添加的工作树中的已签出分支? 我应该如何恢复? - Why does Git allow pushing to a checked-out branch in an added worktree? How shall I recover? 在当前目录中查找已签出代码的大小 - Find size of checked-out code in current directory 检查是否将提取分支并允许将其检出 - Check whether a branch will be fetched and allowed to be checked-out 如何将未版本化的代码合并到Git存储库中? - How to merge unversioned code into Git repository? 如何将git存储库与未版本控制的文件夹同步 - How to synchronize a git repository with an unversioned folder 如何在更改git存储库的autoclrf设置后修复签出文件中的行结尾? - How to fix the line endings in checked out files after changing the autoclrf setting for a git repository? 存储在refs / head之外的ref是否可以被视为分支并签出并作为普通分支进行处理? - Can a ref stored outside refs/heads be considered a branch and checked-out and worked-on as a normal branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM