TeamCity - 在特定文件上构建触发,Mercurial

发布于 2024-08-30 21:52:16 字数 486 浏览 3 评论 0原文

我试图让我的构建仅在我在 Mercurial 中创建标签时触发。我尝试执行此操作的方法是为我的项目创建一个额外的构建配置(标签配置),其中我将 VCS 构建触发器设置为:

+:/.hgtags(仅在标签更新时触发)

-:。 (不要在任何其他文件上触发)

每当我在概述中推送变更集(没有标签)时,我的构建配置(标签配置)显示“X Pending”,我怀疑这是变更集。当我在 Mercurial 中创建标签时,会触发构建 i 并且 X Pending 消失。 然后我剩下要做的就是更新 AssemblyInfo 中的构建/版本号(以某种方式)并部署工件(以某种方式)。

问题一: 这是执行此操作的正确方法还是有其他/更好的方法执行此操作? (我使用 sln2010 runner + NUnit + Mercurial)

问题2: 有没有办法从标签中获取标签名称,以便它可以用于命名工件?

亲切的问候

I'm trying to get my build to trigger only when i create a Tag in Mercurial. The way im trying to do this is by creating an additional Build Config (Tag Conf) for my project where I set the VCS build trigger to:

+:/.hgtags (Trigger only when tags are updated)

-:. (Do not trigger on any other files)

Whenever i push a changeset (without a Tag) in the overview my build conf (Tag Conf) says "X Pending", i suspect this is the changesets. And when I create a Tag in Mercurial, a build i is triggered and the X Pending goes away.
Then all there is left for me todo is to update build/rev numbers in AssemblyInfo (somehow) and deploy the Artifacts(somehow).

Question 1:
Is this the correct way to do this or are there another/better way to do this?
(Im using sln2010 runner + NUnit + Mercurial)

Question 2:
Is there a way to get the Tag name out of the Tag so that it can be used for naming the artifacts for example?

Kind Regards

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

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

发布评论

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

评论(1

风蛊 2024-09-06 21:52:16

Q1:看起来是个好方法。一种更以 Mercurial 为中心的方法是在 TeamCity 用户的 Mercurial.ini 的 [hooks] 部分中放置一个钩子,该钩子要么告诉 TeamCity 开始构建,要么触及启动构建的单独文件。建造。不过,只要您确定 hg update 正在运行(推送本身不会更新 之外的本地工作副本),监视 .hgtags 也可以。 .hg 存储库,不含 hg updatehg pull -u)。

Q2。请记住,由于 .hgtags 文件本身是版本化的,因此如果您执行 hg tag TAGNAME 命令,您已将标签 TAGNAME 应用到 < code>tip 修订版,但这样做时您创建了一个新的变更集,该变更集现在是提示,因此标记为 TAGNAME 的修订版不再是提示。

当您推送所有这些变更集时,您有与我在第一季度提到的相同的考虑因素——您hg更新到哪个版本?如果您hg update -rtip(最简单的操作和默认操作),您将更新到已标记版本之后的一个版本。

幸运的是,有一些模板项对于解决这种棘手的情况非常有用:{latesttag}{latesttagdistance}

有了这些,您可以通过执行以下操作将构建脚本更新到最新标签:

LATESTTAG=$(hg log --template '{latesttag}')
hg update -r $LATESTTAG

这为未标记的构建生成了一个流行的版本字符串:

VERSION=$(hg log --template '{latesttag}+{latesttagdistance}')

这些命令行的 Windows 化留给了因此而瘫痪的读者作为练习。 :)

Q1: Seems a fine way. A more Mercurial-centric way would be to put a hook in the [hooks] section of the TeamCity user's Mercurial.ini that either tells TeamCity to start a build, or touches a separate file that kicks off the build. However, watching for .hgtags is fine too, so long as you're sure hg update is being run (the push in and of itself doesn't update the local working copy outside of the .hg repo without hg update or hg pull -u).

Q2. Remember that since the .hgtags file is itself versioned, if you do a hg tag TAGNAME command you've applied the tag TAGNAME to the tip revision, but in doing so you've created a new changeset that is now the tip, so your revision tagged TAGNAME is no longer the tip.

When you push all those changesets you have the same consideration I alluded to in Q1 -- to which revision do you hg update? If you hg update -r tip (the easiest action and the default) you're updating to one revision past the tagged revision.

Fortunately, there are some template items that are very useful for getting around just that sort of tricky situation: {latesttag} and {latesttagdistance}.

With those you can have a build script update to the latest tag by doing something like:

LATESTTAG=$(hg log --template '{latesttag}')
hg update -r $LATESTTAG

and this makes a popular version string for builds that weren't tagged:

VERSION=$(hg log --template '{latesttag}+{latesttagdistance}')

Windows-ification of those command lines left as an exercise for the thusly crippled reader. :)

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