如何只为标签运行TeamCity构建? [英] How to run a TeamCity build only for tags?

查看:80
本文介绍了如何只为标签运行TeamCity构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个项目会生成NuGet软件包,并将它们发布到内部服务器。我们正在使用语义版本控制,并在Git存储库中使用标签来控制版本号。

I have several projects that produce NuGet packages that I publish to an internal server. We're using semantic versioning, and using tags in our Git repository to control the version numbers.

我这样标记:

git tag -a v1.0.0 -m "tagged"

在TeamCity构建期间,我运行 git describe --long ,它会产生如下输出:

And, during the TeamCity build, I run git describe --long, which produces an output like this:

v1.0.0-0-ge9c047d

输出中的第四个数字是标记之后的提交次数。 0 表示自标记以来未进行任何提交。我将前四个数字用作版本号(顺便说一下,将整个字符串用作AssemblyInformationalVersion)。

The fourth number in the output is the number of commits after the tag. The 0 here means that no commits have been made since the tag. I use these first four numbers as the version number (and, incidentally, the entire string as the AssemblyInformationalVersion).

我有TeamCity软件包并发布了NuGet软件包,但是这里变粘的地方。我只想发布标签,从不提交标签(因为那样的版本号可能是错误的,可能很错误)。

I have TeamCity package and publish a NuGet package, but here's where it gets sticky. I only want to publish tags, never commits after tags (because the version number in that case would be wrong, possibly VERY wrong).

我尝试设置 VCS根目录中的分支规范为 +:refs / tags / *,这将导致所有标签都被构建,但TeamCity也坚持要构建默认分支。如果将默认分支设置为不存在的内容,则会出现错误。

I've tried setting the "branch specification" in the VCS root to "+:refs/tags/*", which causes all the tags to be built, but TeamCity also insists on building the "default branch" as well. If I set the "default branch" to something that doesn't exist, I get an error.

我曾考虑过如果某个特定版本不存在,则尽早结束该版本。不是标签,但是我不知道如何在不失败的情况下完成该操作,这不是我想要的。

I've thought about ending the build early if a particular build isn't a tag, but I can't figure out how to do that without FAILING the build, which isn't what I want.

如何导致一个或一个

推荐答案

如果使用的是TeamCity 8.x,那么还有更多的构建步骤只针对新标签而不是常规提交运行?现在支持 VCS分支触发器,它将允许

If you are using TeamCity 8.x, there is now support for VCS branch triggers, which would allow you to not run builds from the default branch.

尝试以下操作:


  1. 在VCS根目录中将分支规范保留为 +:refs / tags / *

  2. 将VCS构建触发规则更改为:

  1. Leave the Branch Specification in the VCS Root as "+:refs/tags/*"
  2. Change the VCS build trigger rules to:

+:*

-:< default>

-:<default>

这将滤除默认b从触发器开始,您就无需取消构建。

This will filter out the default branch from the trigger and you won't need to cancel the build.

这篇关于如何只为标签运行TeamCity构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆