Hudson 可以配置为构建每个修订版吗?

发布于 2024-07-23 00:01:03 字数 155 浏览 4 评论 0原文

我已经开始尝试使用 Hudson 作为构建服务器。 我正在使用 subversion 并将其配置为每分钟轮询一次。 我看到的问题是,如果修订版 10 的构建需要 5 分钟,并且在此期间有 5 次提交,Hudson 接下来将构建修订版 15。

有没有办法确保构建每个修订版?

I've started experimenting with Hudson as a build server. I'm using subversion and have it configured to poll every minute. The issue I'm seeing is that if a build at revision 10 takes 5 minutes and there are 5 commits during that time, Hudson will next build revision 15.

Is there a way to ensure every revision is built?

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

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

发布评论

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

评论(5

┈┾☆殇 2024-07-30 00:01:03

您必须执行一些操作才能准确构建每个修订版:

  • 向作业添加 REVISION 字符串参数
  • ,将 ${REVISION} 参数附加到存储库 URL,
    例如: https://server/path/myproject${REVISION}
  • 将本地文件夹的名称设置为“myproject”(参见前面的示例),因为 REVISION 变量仅在 URL 中展开,但在创建文件夹时,Hudson 不会展开它,从而产生一个名为: myproject${REVISION} 的文件夹,
  • 从 post-commit 挂钩触发参数化构建,如下所示:
    <代码>
    /usr/bin/wget \
    --auth-no-challenge \
    --无检查证书 \
    --用户=我\
    --密码=mypasswd \
    https://server/path/job/jobname/buildWithParameters?delay=0sec\&REVISION=%40$REV \
    -O /dev/空

如果你想手动触发构建,你有两种可能性:

  • 如果你想构建 HEAD 修订版,则必须将 REVISION 参数留空;
  • 如果你想构建特定修订版,则必须输入@NNN(例如:@1234)。

@ 符号非常重要,因为所有这些技巧都依赖于 Subversion 插件将 URL@NNN 解释为 从 URL 的存储库获取修订版 NNN 。 如果您忘记了 @,Subversion 只会说找不到文件夹 https://server/path/myprojectNNN。 这也是为什么你必须在 wget 命令中的 REVISION=$REV 之间放置 %40%40@ 的转义字符。

You have to do a few things to build exactly each revision:

  • add a REVISION string parameter to your job
  • append the ${REVISION} parameter to the repository URL,
    e.g.: https://server/path/myproject${REVISION}
  • set the name of the local folder to 'myproject' (see previous example), because the REVISION variable is only expanded in the URL, but when creating the folder, Hudson will not expand it, resulting in a folder named: myproject${REVISION}
  • trigger the parameterized build from the post-commit hook, like that:

    /usr/bin/wget \
    --auth-no-challenge \
    --no-check-certificate \
    --user=me \
    --password=mypasswd \
    https: //server/path/job/jobname/buildWithParameters?delay=0sec\&REVISION=%40$REV \
    -O /dev/null

If you want to trigger a build manually, you have two possibilities:

  • if you want to build HEAD revision, you must leave the REVISION parameter empty
  • if you want to build a specific revision, you have to enter @NNN (eg: @1234).

The @ sign is very important because all this trick relies on the fact that Subversion plugin interprets URL@NNN as get revision NNN from repository at URL. If you forget the @, Subversion will just say it can't find folder https://server/path/myprojectNNN. That's also why you have to put %40 between REVISION= and $REV in the wget command, %40 is the escaped character for @.

披肩女神 2024-07-30 00:01:03

我采用了上面的 fchateaus 方法(谢谢!),并将其修改为与 Mercurial 一起使用。

您将需要在中央服务器上编辑 .hg/hgrc,并放入变更组挂钩。 请记住,变更组仅将第一个变更集设置为 HG_NODE 环境变量,因此您必须执行 hg Tip 来获取真正的提示节点并通过 URL 传递它。 一句台词里有一点技巧,但我想通了。

这就是您为在 Windows 上运行的 Hudson 所做的事情。

[hooks]
# this uses wget to hit the hudson url responsible for starting a build - %HG_NODE% only gets first changeset of changegroup, so use hg tip to grab changeset most recently added instead
changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/buildWithParameters?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G
# TODO: when Hudson implements polling with parameters, change to something like this
#changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/polling?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G

I took fchateaus approach above (thanks man!) and modified it to work with Mercurial.

You will need to edit .hg/hgrc on the central server, and put in a changegroup hook. Keep in mind that changegroups only set the first changeset to the HG_NODE environment variable, so you have to do a hg tip to grab the real tip node and pass that along via URL instead. A bit of a trick to do in a one-liner, but I figured it out.

This is what you would do for Hudson running on Windows.

[hooks]
# this uses wget to hit the hudson url responsible for starting a build - %HG_NODE% only gets first changeset of changegroup, so use hg tip to grab changeset most recently added instead
changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/buildWithParameters?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G
# TODO: when Hudson implements polling with parameters, change to something like this
#changegroup.hudson = for /f "tokens=*" %G IN ('hg tip --template {node}') DO "C:\Program Files (x86)\UnxUtils\usr\local\wbin\wget" --non-verbose --spider http://HudsonServer:8080/job/{Repository}/polling?HgRevId=%G | ECHO Result of Hudson Polling Request For Node %G
淡淡の花香 2024-07-30 00:01:03

<块引用>

确保每次提交都在 Hudson 中构建的关键是“参数化构建”,并且只有当使用不同的参数值触发构建时,Hudson 才会认为它是新构建,并且应该保存在构建队列中。 或者 Hudson 不会记录它,因为它认为与之前的构建相比,它毫无意义

。 您可以单击“立即构建”触发构建三次,并将构建参数保留为“空”。 您将看到 Hudson 队列中只有前两个构建。 第三个将被忽略:P酷,但它真的很糟糕,它在某些文档中没有找到,但在我的多次实验中:(

The key to make sure every commit is built in Hudson is "Parameterized Build" and ONLY IF trigger build with different parameter values, hudson will think it's new build and should be held in build queue. Or it won't be recorded by Hudson since it consider it's meaningless build compared with previous one

e.g. you can click "Build Now" to trigger build for three times and just leave the build para as "null". you will see only first two builds are in Hudson queue. The third one will be ignored :P cool but it's really bad that it's not found in some document but with my experiments for times :(

池予 2024-07-30 00:01:03

在构建配置的 SCM 部分中,您应该有“构建触发器”部分和选项“触发器远程构建(例如,从脚本)”。 根据该选项旁边的帮助信息,您可以编写提交后操作的脚本,以便每次提交都会触发新的构建。 由于 hudson 有构建队列,因此您应该构建每个修订版本。

这是一个可以帮助您的链接:https://hudson.dev.java.net/build。 :

下面是如何使用参数开始构建作业的示例(有关详细信息,请参阅我的评论)
http://wiki.hudson-ci.org/display/HUDSON/Parameterized+构建

In SCM part of build configuration you should have Build Triggers section and option "Trigger builds remotely (e.g., from scripts)". According to help info next to that option you can script post-commit action so every commit would fire new build. As hudson has build's queue you should have every revision built.

Here's a link that could help you: https://hudson.dev.java.net/build.html

Here's example how to start build job with parameters (see to my comment for details):
http://wiki.hudson-ci.org/display/HUDSON/Parameterized+Build

晒暮凉 2024-07-30 00:01:03

Hudson 尚不具备此功能,但邮件列表中已多次要求提供此功能。 请参阅问题 673

Hudson does not yet have this capability, but its been asked for a few times on the mailing list. See issue 673

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