将构建的二进制文件保存到 SCM 中
毫无疑问将 src 代码保存到 SCM 中,但是生成的构建呢?考虑到您有许多具有不同版本且触手可及的客户,而不是将它们保存到文件系统中,将它们保存到 SCM 中是一个很好的做法吗?
No doubt about saving src code into SCM, but what about the generated builds ? Instead having them into a file system, would be a good practice to save them into a SCM considering that you have many customers with diff versions and within reach ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应将生成的二进制文件存储在版本控制中。它们应该是使用存储库中的构建脚本编译和捆绑存储库中的源代码的输出。如果您的构建由于某种原因无法重现,请修复原因。不要滥用版本控制,将其应用于不会发展的工件。
请注意,这全部参考您的二进制文件。如果您有外部依赖项,有时将它们置于版本控制之下是合理的,因为它们是构建过程的输入。这可能是第三方库或工具链组件之类的东西。
如果您只需要备份已发送给客户的内容,请将完整的映像或存档放入与存储库相同的备份文件系统中。将它们保存在文件系统之上的 VCS 额外打包层中并没有什么特别的。如果说有什么不同的话,那就是不太可靠,因为还有一个可能的腐败点。在任何一种情况下,如果您关心这些存档版本的完整性,您应该在发布它们时获取它们的加密哈希值,并将它们与存档一起记录,以便您以后可以验证它们。如果您真的很偏执,请使用未保存在该文件服务器上的私钥对校验和文件进行签名。
You should not store generated binaries in version control. They should be the output of compiling and bundling the source code in your repository using the build scripts in your repository. If your builds are not reproducible for some reason, go fix the cause. Don't abuse version control by applying it to artifacts that don't evolve.
Note that this is all with reference to your binaries. If you have external dependencies, it is sometimes reasonable to keep them under version control, as they are inputs to your build process. This would be things like third-party libraries or toolchain components.
If you just need a backup of what you've shipped to customers, drop complete images or archives in the same backed-up file system that you keep your repository on. There's nothing special about keeping them in a VCS's extra layer of packaging on top of the file system. If anything, that's less reliable, as there's one more point of possible corruption. In either case, if you care about the integrity of those archived builds, you should take cryptoographic hashes of them when they ship, and record those alongside the archives, so that you can verify them later. If you're being really paranoid, sign the checksum file with a private key that's not kept on that file server.
当然,您将无法查看二进制文件的差异,但任何类型的文件都可以放入版本控制中。
我在 SVN 中从来没有遇到过二进制文件的问题,但如果你不小心,在其他一些 SCM(Git,可能是其他)中,它们可能会被损坏。
如果您使用 SVN,需要考虑的另一件事是,每当您上传新版本的二进制文件时,存储库使用的空间量都会随着二进制文件的大小而增加。发生这种情况是因为区分二进制文件实际上没有意义,因此每个连续的副本都必须完整存储。因此,如果服务器辅助存储空间是一个问题,或者您的二进制文件很大,您可能需要考虑替代解决方案。
那么...你使用SVN吗? :)
Of course you won't be able to view diffs of the binaries, but any kind of file can be put into version control.
I've never had a problem with binaries in SVN, but if you aren't careful, in some other SCMs (Git, possibly others) they may become corrupted.
If you're using SVN, another thing to consider is that anytime you upload a new version of the binary, the amount of space used by your repo will grow by as much as the size of the binary. This happens because it doesn't really make sense to diff binaries, so every successive copy has to be stored whole. So if server secondary storage space is an issue, or your binaries are large, you may want to consider an alternative solution.
So... are you using SVN? :)
不建议将生成的工件保存到 SCM 中。
不知道你正在开发什么样的程序,对于Java项目,好的做法是使用 Maven 来构建工件并将其存储到 Maven 存储库中。
请阅读这篇文章,了解有关 Maven 存储库的更多信息以及为什么不放置二进制文件写入SCM。
It's not recommended to save generated artifacts into SCM.
Don't know what kind of program you're developing, for Java project, the good practice is using Maven to build and storing artifacts into Maven Repository.
Please read this article for more about Maven Repository and why not put binaries into SCM.