将文件从Jenkins工作区提交到SVN [英] Commit file from Jenkins workspace to SVN

查看:474
本文介绍了将文件从Jenkins工作区提交到SVN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Subversion存储库中有一个保存的项目,并使用Jenkins进行编译.当我运行构建时,Jenkins将项目拉入工作区目录.我需要将一个更改过的文件从Jenkins工作区提交到Subversion. 我该怎么办?

I have a saved project in Subversion repository and compiles it with Jenkins. When I run the build, Jenkins pulls project into workspace directory. I need commit one changed file from Jenkins workspace into Subversion. How can I do it??

感谢您的回答...

推荐答案

能否提供更多详细信息?确切地说,这个文件是什么,为什么要在您的Jenkins构建中提交它?您正在构建什么(Java?C ++ ?. NET?),以及如何构建它?

Can you give a few more details? Exactly what is this file, and why does it need to be committed as part of your Jenkins build? What are you building (Java? C++? .NET?) and how are you building it?

通常,除了 source 文件之外,您不应将任何东西置于版本控制之下.也就是说,如果可以构建它,则不应将其放入版本控制中.许多人喜欢将其内置代码提交到版本控制系统中,但这通常是一个大错误.二进制文件更大,并且很少差异.这导致源存储库的编译代码达到90%-几乎所有代码都已过时.对于Subversion来说,这尤其成问题,因为Subversion无法(轻松地)删除过时的代码.

Normally, you shouldn't put anything under version control except source files. That is, if you can build it, you shouldn't put it into version control. A lot of people like to commit their built code into their version control system, but this is usually a big mistake. binary files are much bigger and rarely diff. This results in a source repository that's 90% compiled code -- almost all of it obsolete. This is especially problematic with Subversion which doesn't have a way to (easily) remove obsolete code.

Jenkins具有一项功能,可让您存档内置文件以便于访问.我们一直在使用它.我们构建了代码,该程序可在Jenkins中下载.更好的是,Jenkins将删除较早的版本(您可以保存最近的X个版本,或者仅保存X天以下的版本).而且,如果您有候选发布版本,则可以锁定该版本以防止其被删除.

Jenkins has a feature that allows you to archive your built files for easy access. We use this all the time. We build our code, and the program is available in Jenkins for downloads. Even better, Jenkins will delete older builds (you can save the last X builds or save only builds younger than X days). And if you have a release candidate build, you can lock that build to prevent it from being deleted.

不过,如果您坚持要这样做,则可以做几件事,并且需要注意以下几点:

Still, if you insist on doing this, there are several things you can do and things you have to watch out for:

  1. 当您设置了Jenkins来自动构建每个更改,并且在版本控制系统中提交了更改时,Jenkins将看到并开始新的构建.然后,詹金斯保存更改,查看更改,然后进行另一次构建.确保应该在进行构建时从Jenkins的考虑中排除文件或目录.您可以在指定结帐的URL时指定此名称.

  1. When you have Jenkins setup to automatically build each change, and you commit a change in your version control system, Jenkins will see that, and start a new build. Then, Jenkins saves the change, sees the change, and does another build. Make sure you exclude the files or directories from Jenkins' consideration when it should do a build. You can specify this when you specify the URL of the checkout.

与大多数版本控制系统不同,Subversion是独立于客户端的.有一个针对客户的实际API. Jenkins不需要标准的Subversion命令行客户端,因此请确保已安装.确保安装与SVNKit客户端内置的Jenkins兼容的客户端.尤其如此,因为Subversion 1.6、1.7和1.8均采用不同的客户端格式.

Unlike most version control systems, Subversion was made to be client independent. There's an actual API for clients. The standard Subversion command line client isn't needed in Jenkins, so make sure it's installed. Make sure you install a client compatible with the Jenkins built in SVNKit client. This is especially true since Subversion 1.6, 1.7, and 1.8 all take a different client format.

您可以在Jenkins中向您的构建添加多个构建步骤.只需添加一个新的Shell脚本或批处理脚本步骤,然后添加svn commit -m "comment of some sort"步骤.处理完前两点后,这很简单.但是,请仔细考虑为什么要这么做.

You can add multiple build steps to your build in Jenkins. Just add a new shell script or batch script step, and add in a svn commit -m "comment of some sort" step. It's pretty simple to do once you've taken care of the first two points. However, please think carefully why you're doing this.

正如我之前所说,在99.9999%的时间内,您不应该使用Jenkins来提交它构建的更改.我确定某处存在0.0001%的原因,但我从未见过.如果要使其他项目可以通用访问构建文件,请使用Jenkin的功能来存档构建文件.

As I said before, 99.9999% of the time, you shouldn't be using Jenkins to commit changes it built. I'm sure that 0.0001% reason exists somewhere, but I've never seen it. If you want to make built files universally accessible to your other projects, use Jenkin's ability to archive built files.

如果另一个版本需要Jenkins正在构建的产品,则可以使用

If a product Jenkins is building is needed for another build, you can use the Copy Artifact Plugin to copy a build artifact to another job, and then fire off that job. Even better, use a release repository system. In Java, you can use a Maven release repository like Nexus or Artifactory. To use and deploy artifacts to that repository, you can use Ivy or Maven or Gradle. If you are building .NET, look at Nuget.

这篇关于将文件从Jenkins工作区提交到SVN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆