基于maven2的持续集成
我正在尝试弄清楚如何使用 Maven 设置持续集成。
我想要的是:
- 检查 SVN 中的新内容
- 如果检测到更改,请检查它们
- 构建和部署
我认为所有这些都可以推送到某个 shell 脚本中,以使其由 cron 调用。 因此,我们将进行自动持续集成(例如,每晚构建)
我知道 Maven 有 SCM 插件用于与版本控制系统配合使用,但我不知道如何让它检查存储库中的更改并根据结果启动结账。
所以我问观众:)
PS 我忘了提 - 我对任何现有的应用程序都不感兴趣! 它们对于我的 VPS 服务器来说太重了。 请不要建议他们
I am trying to figure out how to setup continuous integration using maven.
What I want is:
- Check for new stuff in SVN
- If changes are detected, check them out
- Build and deploy
I think all of this can be pushed into some shell script to make it be invoked by cron. Thus we will have automated continuous integration (nightly builds, for example)
I know that maven has SCM plugin for working with version control systems, but I don't know how to make it check for changes in repository and based on the results launch checkout.
So I am asking the audience :)
PS I forget to mention - I am NOT INTERESTING in any of existing applications! They are too heavy for my VPS server. Please do not advise them
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您看过 hudson 吗?
Have you looked at hudson?
下载并安装 JetBrains TeamCity - 专业版免费。 它是一个出色的持续集成服务器,支持 SVN 和 Maven(除其他外)。
Download and install JetBrains TeamCity - the Professional edition is free. It is a superb continuous integration server that supports SVN and Maven (amongst other things).
我们使用一个名为 Luntbuild 的应用程序来管理类似的事情。
,然后应用程序监视 SVN 的更改并构建/部署您的应用程序。 。
We use an application called Luntbuild to manage everthing like that.
Then the application monitors SVN for changes and builds/deploys your apps...
看看 Hudson。 它是免费的、开源的、积极开发的,有几十个有用的插件,有很好的 Maven2 支持,而且一切都很棒。
Stack Overflow 上也经常讨论。
Take a look at Hudson. It's free, open-source, actively developed, has dozens of useful plugins, has great Maven2 support, and is all around awesome.
It's also frequently discussed on Stack Overflow.
我建议使用公认的 CI 工具来管理它,因为 CI 的功能还有更多不仅仅是构建。
但如果您决定自己推出,则可以使用 maven-scm-plugin 中的一些目标并捕获输出。
假设您有项目的本地副本,因此您可以访问 pom,您可以运行 status 命令来检查更改,并解析输出检查是否有任何更改
使用的目标是:
如果您看到任何更改的文件,那么您可以检查更改并调用您的构建。
但请注意,maven-scm-provider-svn链接文本中存在一个错误意味着可以跳过更改的文件! 您可能最好直接调用 Subversion 并解析其输出。
例如,以下内容将清除以前的构建,检查任何更改的内容,然后运行部署目标。
如果您没有该项目的工作副本,可以使用 scm :bootstrap 目标来获取它。 如果您在 pom 中设置了一些属性,则可以重用该 pom 来引导多个项目。
例如,如果您向其传递适当的命令行参数,下面的 pom 可以引导任何项目:
要使 Maven 与 subversion 一起工作,您需要配置 POM 的 scm 部分:
作为轮询的替代方法更改,请考虑添加挂钩到 subversion 以便触发构建当进行更改时。 还有另一个问题可以给出给你一个关于这样做的指示。
I'd recommend using a recognised CI tool for managing this as there is more to CI than just the build.
But if you are determined to roll your own, you can use some of the goals from the maven-scm-plugin and capture the output.
Assuming you have a local copy of the project so you've access to the pom, you can run the status command to check for changes, and parse the output checking for any changes
The goal to use is:
If you see any changed files, then you can check out the changes and invoke your build.
Beware though, there is a bug in maven-scm-provider-svnlink text that means changed files can be skipped! You may be better invoking Subversion directly and parsing its output.
For example the following will clear up a previous build, check out any changed content and then run the deploy goal.
If you don't have a working copy of the project, you can use the scm:bootstrap goal to obtain it. If you set up some properties in a pom you can reuse the pom to bootstrap multiple projects.
For example the pom below can bootstrap any project if you pass the appropriate command line arguments to it:
To make Maven work with subversion you need to configure the scm section of the POM:
As an alternative for polling for changes, consider adding a hook to subversion so that the build is triggered when a change is made. There's another question that can give you a pointer on doing that.
Maven 是一个用于存储代码和构建项目的存储库。 就我个人而言,我不会将其用作持续集成工具。
看看 hudson,我想您会找到更多您想要的东西。 其他持续构建工具也适合您。 它将通过从存储库获取最新版本的代码并按照您想要的任何计划(甚至是非计划的手动构建)构建它来工作。
Maven is a repository for storing code and building projects. Personally I wouldn't use it as a continuous integration tool.
Take a look at hudson, and I think you'll find more what you're looking for. Other continuous build tools will work for you as well. It will work by getting the latest version of your code from your repository, and building it on any schedule you want (or even a non-scheduled manual build).