与 Hudson 和 Mercurial 持续集成

发布于 2024-10-19 16:11:15 字数 711 浏览 4 评论 0原文

我正在尝试找出设置新流程的最佳方法,并希望获得一些反馈:

我们正在使用 Mercurial 和 Hudson 来实现 CI 目的。 我领导着一个由多名开发人员组成的团队。

现在,当票进来时,我将它们分配给适当的开发人员,他们检查主干并进行更改。

我的目录结构如下:

PROJECT/bugfixes

现在,我的开发人员当前将他们的修复克隆到 PROJECT/bugfixes/bugticket (这是经过适当更改的 PROJECT 的克隆)

在本周末,我可以查看错误修复并看到几个错误单目录,我想将其中一些(我选择我想要的)合并到发布版本中:

PROJECT/releasebuild

我将项目克隆到发布版本中,然后拉下我想要的错误单并将它们合并到其中。

我开始与 Hudson 一起玩,我想它将更好地服务于我的目的。

现在,我的问题是:

  • 我如何设置 Hudson 来执行上述任务?我认为我的开发人员应该使用分支而不是 PROJECT/bugfixes/bugtickets 目录。这是正确的吗?

  • 对于我想要导入的每个分支,我应该为该特定分支创建一个新的 Hudson 项目吗? Hudson 的 Mercurial 插件似乎只接受一个分支。

我应该有更好的方法吗?

I am trying to figure out the best way to set our new process and would love to get some feedback:

We are using Mercurial and Hudson for CI purposes.
I am leading a team with several developers.

Now, when tickets come in, I assign them to their appropriate developers who check out trunk and make their changes.

I have my directory structure as follows:

PROJECT/bugfixes

Now, my developers currently clone their fixes to PROJECT/bugfixes/bugticket (this is a clone of PROJECT with the appropriate changes)

At the end of the week, I can look in bugfixes and see several bugtickets directory and I would like to merge some of the them (I choose which ones I want) into a release build:

PROJECT/releasebuild

I clone PROJECT into releasebuild and I pull down the bugtickets I want and merge them in.

I started playing with Hudson and I think it will serve my purposes better.

So now, my questions:

  • How can I set up Hudson to perform the above task? I think my developers should use branches rather than the directory of PROJECT/bugfixes/bugtickets. Is this correct?

  • For each branch I want to import, should I create a new Hudson project for that particular branch? It looks like the Mercurial plugin for Hudson only accepts one branch.

Is there a better way I should do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

生生漫 2024-10-26 16:11:15

也许最简单的方法是为每个分支机构设置一个 hudson 工作。在之前的项目中,我实际上发现不使用 hudson Mercurial 插件更容易。相反,我设置了一个项目(仅适用于默认分支),该项目执行了 hg purge (以删除不属于存储库的任何工件),然后执行 hg pull (来自主存储库),然后是 hg update default。然后它就完成了构建。

我在存储库中设置了一个 Mercurial 钩子,每当一个或多个变更集提交到存储库时,它都会使用 hudson CLI 触发 hudson 构建。

当然,从那时起事情可能已经发生了变化 - 我已经大约两年没有考虑 hudson/hg 集成了。

这是我使用的钩子 - 将其更新到最新版本的 hudson 或 jenkins,或者处理多个分支应该相当简单。

"""
[hooks]
commit.hudson = python:(path to)/hudson.py:hudson_build_trigger
changegroup.hudson = python:(path to)/hudson.py:hudson_build_trigger
"""

from mercurial.i18n import _
from mercurial import localrepo, util, commands, cmdutil, extensions
from mercurial.context import changectx
from mercurial.node import nullrev
import os, os.path, subprocess

def extsetup(ui):
    pass

def hudson_build_trigger(ui, repo, node, **kwargs):
    """Triggers a hudson build. Uses a [hudson] section in hgrc. The 'jar', 'url'
    and 'job' parameters are required, the 'branch' parameter defaults to 'default'
    if not specified e.g.

    [hudson]
    jar = /path/to/hudson-cli.jar
    url = http://server:port/path/to/hudson
    job = hudson_mercurial_job
    branch = developer1

    Use as a commit and changegroup hook e.g.:

    [hooks]
    commit.hudson = python:(path to)/hudson.py:hudson_build_trigger
    changegroup.hudson = python:(path to)/hudson.py:hudson_build_trigger
    """

    jar = ui.config('hudson', 'jar', '')
    url = ui.config('hudson', 'url', '')
    job = ui.config('hudson', 'job', '')
    branch = ui.config('hudson', 'branch', 'default')

    if not jar or not os.path.exists(jar) or not url or not job:
        raise util.Abort(_('must specify Hudson CLI jar, URL and job'))

    ctx = repo[node]

    for rev in range(ctx.rev(), len(repo)):
        if repo[rev].branch() == branch:
            # Trigger a hudson build
            result = subprocess.call([
                'java',
                '-jar',
                jar,
                '-s',
                url,
                'build',
                job
            ])

            if result != 0:
                raise util.Abort(_('failed to trigger Hudson build'))

            ui.write(_("triggered build for %s\n" % (job,)))
            break

Probably the easiest way is to set up a hudson job per-branch. On a previous project, I actually found it was easier not to use the hudson mercurial plugin. Instead, I set up a project (for the default branch only) which did a hg purge (to remove any artifacts that were not part of the repository) then a hg pull (from the master repo) followed by hg update default. Then it did the build.

I set up a mercurial hook in the repository that triggered a hudson build using the hudson CLI any time that one or more changesets were committed to the repository.

Of course, things may have changed since then - I haven't looked at the hudson/hg integration for about 2 years.

Here's the hook I used - it should be fairly simple to update it to the latest version of hudson or jenkins, or to handle multiple branches.

"""
[hooks]
commit.hudson = python:(path to)/hudson.py:hudson_build_trigger
changegroup.hudson = python:(path to)/hudson.py:hudson_build_trigger
"""

from mercurial.i18n import _
from mercurial import localrepo, util, commands, cmdutil, extensions
from mercurial.context import changectx
from mercurial.node import nullrev
import os, os.path, subprocess

def extsetup(ui):
    pass

def hudson_build_trigger(ui, repo, node, **kwargs):
    """Triggers a hudson build. Uses a [hudson] section in hgrc. The 'jar', 'url'
    and 'job' parameters are required, the 'branch' parameter defaults to 'default'
    if not specified e.g.

    [hudson]
    jar = /path/to/hudson-cli.jar
    url = http://server:port/path/to/hudson
    job = hudson_mercurial_job
    branch = developer1

    Use as a commit and changegroup hook e.g.:

    [hooks]
    commit.hudson = python:(path to)/hudson.py:hudson_build_trigger
    changegroup.hudson = python:(path to)/hudson.py:hudson_build_trigger
    """

    jar = ui.config('hudson', 'jar', '')
    url = ui.config('hudson', 'url', '')
    job = ui.config('hudson', 'job', '')
    branch = ui.config('hudson', 'branch', 'default')

    if not jar or not os.path.exists(jar) or not url or not job:
        raise util.Abort(_('must specify Hudson CLI jar, URL and job'))

    ctx = repo[node]

    for rev in range(ctx.rev(), len(repo)):
        if repo[rev].branch() == branch:
            # Trigger a hudson build
            result = subprocess.call([
                'java',
                '-jar',
                jar,
                '-s',
                url,
                'build',
                job
            ])

            if result != 0:
                raise util.Abort(_('failed to trigger Hudson build'))

            ui.write(_("triggered build for %s\n" % (job,)))
            break
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文