Hudson 与 Subversion:使用 Java 或 Ant 在 Windows 上提交后构建

发布于 2024-12-01 12:58:06 字数 569 浏览 2 评论 0原文

我的任务是让 Hudson 在提交后开始新的构建。正如我在此处阅读的那样,它是通过使用 svn post-commit 完成的钩。问题是我不想使用 VBScript,因此它依赖于平台。正如我所看到的,此 VBScript 中唯一重要的事情是使用 svnlook 命令和 http://server/subversion/${UUID}/notifyCommit?rev=$REV url 。就我而言,我可以做同样的事情,例如使用一个java程序(它需要修订版、存储库位置等参数)。

请您解开http:// /server/subversion/${UUID}/notifyCommit?rev=$REV 网址?我需要所有可能的变体。如果有人可以描述与 Hudson 交互的整个过程(它是在收到此请求后执行的内部流程链),那就太好了

编辑我真的需要提交后行为,而不是轮询机制。

My task is to make Hudson starting a new build after a commit. As I've read here it is done by using svn post-commit hook. The problem is I don't want to use VBScript so that is is platform-dependent. As I can see the only important things in this VBScript are using svnlook command and http://server/subversion/${UUID}/notifyCommit?rev=$REV url. As far as I am concerned I can do the same thing just using, for example, a java program (which requires parameters as revision, repository location, etc.)

Can you, please, unravel the mystery of the http://server/subversion/${UUID}/notifyCommit?rev=$REV url? I need all possible variants. It would be great if sombody can describe the whole process of interaction with Hudson (it's internal processes' chain which execute after it gets this request)

EDIT I really need the post-commit behavior, not a polling mechanism.

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

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

发布评论

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

评论(4

爱要勇敢去追 2024-12-08 12:58:06

最快的跨平台解决方案是在 SVN 服务器上安装 Cygwin(假设 SVN 机器运行 Windows)并使用提供的 shell 脚本:

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`
/usr/bin/wget \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --output-document "-" \
  --timeout=2 \
  http://server/subversion/${UUID}/notifyCommit?rev=$REV

我需要 http://server/subversion/${UUID}/notifyCommit?rev=$REV

的所有可能变体

为什么?那一个可以满足您的所有需求。

  • server Jenkins 服务器
  • ${UUID} 存储库的唯一 ID。
  • $REV 新版本。

您也可以使用提交后挂钩中的某些内容来 ping:http://YOURHOST/jenkins/job/PROJECTNAME/build。您不会为每个提交获得一个新的构建,但是如果您在几秒钟之内有两次提交,您真的想要每次构建吗?


只是出于好奇,您是否想要后期提交,因为您发现 SVN 服务器变得非常慢?如果是的话,SVN 盒子运行在什么操作系统上?您可能会遇到操作系统的限制,如果您迁移到 Linux 或 Windows 服务器版本,您将获得更好的性能(在相同情况下)。

The quickest, cross platform solution is to install Cygwin on the SVN server (assuming the SVN box is running Windows) and use the suppiled shell script:

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`
/usr/bin/wget \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --output-document "-" \
  --timeout=2 \
  http://server/subversion/${UUID}/notifyCommit?rev=$REV

I need all possible variants of http://server/subversion/${UUID}/notifyCommit?rev=$REV

Why? That one does all you need.

  • server The Jenkins server
  • ${UUID} The unqiue ID for the repository.
  • $REV The new revision.

You could also just use something in the post-commit hook to ping: http://YOURHOST/jenkins/job/PROJECTNAME/build. You will not get a fresh build for every commit, but if you have two commits within seconds of each other do you really want each built?


Just out of curiosity, do you want the post commit as you have found your SVN server getting incredibly slow? If so, what OS is the SVN box on? You might be hitting limits of the OS and you would get much better performance (on the same tin) if you moved to Linux or a server edition of Windows.

寻找一个思念的角度 2024-12-08 12:58:06

您不一定需要使用 svn hook。只需让 Hudson 经常轮询存储库以了解更改即可。此外,您可能需要使用一个安静期来考虑连续的多个提交(否则可能会触发多个构建)。

从您发布的链接:

Jenkins 可以轮询 Subversion 存储库以获取更改,虽然这相当有效,但这种情况最多只能每分钟发生一次,因此您可能仍需要等待一整分钟才能 Jenkins 检测到更改。

我不认为等待一分钟有那么大的问题。在大多数情况下,您甚至可能没有注意到它。

You don't necessarily need to use a svn hook. Just make Hudson poll the repo for changes frequently. Additionally you might want to employ a quiet period in order to account for multiple commits in a row (which otherwise might trigger multiple builds).

From the link you posted:

Jenkins can poll Subversion repositories for changes, and while this is reasonably efficient, this can only happen up to every once a minute, so you may still have to wait a full minute before Jenkins detects a change.

I wouldn't consider having to wait a minute that big a problem. In most cases you might not even notice it.

谁把谁当真 2024-12-08 12:58:06

我是这样做的:我将 hudson 配置为每分钟检查一次更改(模式:* * * * *)。效果非常好。唯一可能发生的问题是,如果在此时间间隔内提交的两个项目相互依赖,那么 hudson 首先会构建错误的项目。

I've done it like this: I configured hudson to check every minute for changes (Pattern: * * * * *). It works quite good. The only problem which can occur is that if two projects which have been commited within this interval and are dependent on each other, that hudson builds the wrong one first.

街角卖回忆 2024-12-08 12:58:06

重要提示 - 网络上的文章都没有明确提到您必须在选中“触发远程构建”的情况下创建的作业。这是第一步,此步骤本身为您提供了必须放入 subversion HOOK 脚本中的 URL

相应的钩子脚本

!/bin/sh

REPOS="$1"
REV="$2"
/usr/bin/wget \
--header "Content-Type:text/plain;charset=UTF-8" \
--post-data "`/usr/local/bin/svnlook changed --revision $REV $REPOS`" \
--output-document "-" \
--timeout=2 \
http://build.development.com:8080/job/HdsVp/build?token=SVN_CHANGE

Important - None of the article on web clearly mentions about the job that you have to create with "Trigger Build Remotely" checked. This is the first step and this step itself gives you URL that you have to put in your subversion HOOK scriptHere is what you have to select while creating your job that would be called when commit occurs

corresponding hook script

!/bin/sh

REPOS="$1"
REV="$2"
/usr/bin/wget \
--header "Content-Type:text/plain;charset=UTF-8" \
--post-data "`/usr/local/bin/svnlook changed --revision $REV $REPOS`" \
--output-document "-" \
--timeout=2 \
http://build.development.com:8080/job/HdsVp/build?token=SVN_CHANGE
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文