基于maven2的持续集成

发布于 2024-07-28 23:45:37 字数 354 浏览 3 评论 0原文

我正在尝试弄清楚如何使用 Maven 设置持续集成。

我想要的是:

  1. 检查 SVN 中的新内容
  2. 如果检测到更改,请检查它们
  3. 构建和部署

我认为所有这些都可以推送到某个 shell 脚本中,以使其由 cron 调用。 因此,我们将进行自动持续集成(例如,每晚构建)

我知道 Maven 有 SCM 插件用于与版本控制系统配合使用,但我不知道如何让它检查存储库中的更改并根据结果启动结账。

所以我问观众:)

PS 我忘了提 - 我对任何现有的应用程序都不感兴趣! 它们对于我的 VPS 服务器来说太重了。 请不要建议他们

I am trying to figure out how to setup continuous integration using maven.

What I want is:

  1. Check for new stuff in SVN
  2. If changes are detected, check them out
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

久随 2024-08-04 23:45:38

您看过 hudson 吗?

Have you looked at hudson?

2024-08-04 23:45:38

下载并安装 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).

溺ぐ爱和你が 2024-08-04 23:45:38

我们使用一个名为 Luntbuild 的应用程序来管理类似的事情。

  • 首先,您创建一个项目,
  • 指向 ant、maven 或您正在使用的其他构建器(我们只使用 ant 脚本)
  • 定义 SVN 适配器(或其他 VCS)

,然后应用程序监视 SVN 的更改并构建/部署您的应用程序。 。

We use an application called Luntbuild to manage everthing like that.

  • First you make a project
  • Point to ant, maven or some other builder you're using (We just use ant-scripts)
  • Define an SVN adapter (or other VCS)

Then the application monitors SVN for changes and builds/deploys your apps...

追我者格杀勿论 2024-08-04 23:45:37

看看 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.

可遇━不可求 2024-08-04 23:45:37

我建议使用公认的 CI 工具来管理它,因为 CI 的功能还有更多不仅仅是构建。

但如果您决定自己推出,则可以使用 maven-scm-plugin 中的一些目标并捕获输出。

假设您有项目的本地副本,因此您可以访问 pom,您可以运行 status 命令来检查更改,并解析输出检查是否有任何更改
使用的目标是:

mvn scm:status

如果您看到任何更改的文件,那么您可以检查更改并调用您的构建。
但请注意,maven-scm-provider-svn链接文本中存在一个错误意味着可以跳过更改的文件! 您可能最好直接调用 Subversion 并解析其输出。

例如,以下内容将清除以前的构建,检查任何更改的内容,然后运行部署目标。

mvn clean scm:checkout deploy

如果您没有该项目的工作副本,可以使用 scm :bootstrap 目标来获取它。 如果您在 pom 中设置了一些属性,则可以重用该 pom 来引导多个项目。

例如,如果您向其传递适当的命令行参数,下面的 pom 可以引导任何项目:

mvn scm:bootstrap -DscmUserName=me -DscmPassword=mypass -DscmConnectionUrl=scm:svn:http://myserver/myproject/trunk

<project>
  [...]
  <packaging>jar</packaging>
  <version>0.0.1</version>
  <name>SCM bootstrapper</name>
  <url>http://somecompany.com</url>
  <scm>
    <connection>${scmConnectionUrl}</connection>
    <developerConnection>${scmDeveloperConnectionUrl}</developerConnection>
    <url>${scmUrl}</url>
  <scm>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <goals>install</goals>
          <username>${scmUsername}</username>
          <password>${scmPassword}</password>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
  <properties>
    <scmDeveloperConnectionUrl>dummy</scmDeveloperConnectionUrl>
    <scmConnectionUrl>dummy</scmConnectionUrl>
    <scmUrl>dummy</scmUrl>
    <scmUsername>dummy</scmUsername>
    <scmPassword>dummy</scmPassword>
  </properties>
</project>

要使 Maven 与 subversion 一起工作,您需要配置 POM 的 scm 部分:

<scm>
  <connection>scm:svn:http://path/to/project</connection>
  <developerConnection>scm:svn:http://path/to/project/tags/version</developerConnection>
  <url>scm:svn:http://path/to/project/tags/version</url>
</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:

mvn scm:status

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.

mvn clean scm:checkout deploy

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:

mvn scm:bootstrap -DscmUserName=me -DscmPassword=mypass -DscmConnectionUrl=scm:svn:http://myserver/myproject/trunk

<project>
  [...]
  <packaging>jar</packaging>
  <version>0.0.1</version>
  <name>SCM bootstrapper</name>
  <url>http://somecompany.com</url>
  <scm>
    <connection>${scmConnectionUrl}</connection>
    <developerConnection>${scmDeveloperConnectionUrl}</developerConnection>
    <url>${scmUrl}</url>
  <scm>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <goals>install</goals>
          <username>${scmUsername}</username>
          <password>${scmPassword}</password>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
  <properties>
    <scmDeveloperConnectionUrl>dummy</scmDeveloperConnectionUrl>
    <scmConnectionUrl>dummy</scmConnectionUrl>
    <scmUrl>dummy</scmUrl>
    <scmUsername>dummy</scmUsername>
    <scmPassword>dummy</scmPassword>
  </properties>
</project>

To make Maven work with subversion you need to configure the scm section of the POM:

<scm>
  <connection>scm:svn:http://path/to/project</connection>
  <developerConnection>scm:svn:http://path/to/project/tags/version</developerConnection>
  <url>scm:svn:http://path/to/project/tags/version</url>
</scm>

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.

茶色山野 2024-08-04 23:45:37

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文