排队TFS通过PowerShell的构建 [英] Queueing TFS builds via PowerShell

查看:183
本文介绍了排队TFS通过PowerShell的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TFS2012都与一个2010生成代理一个2010生成控制器。也有多个2012生成代理1 2012生成控制器。

我们有多个构建我们的软件的多个版本。该版本根据惯例命名例如Foo_version_1_0和Foo_version_2_0。

当我在我的本地机器上运行该code,所有这些版本进行排队。当我在2012年的生成代理手动运行该code,该版本是排队。当我在2010年生成代理手动运行该code,无版本是排队。当code与TFS触发构建的一部分执行(无论是在2010年或2012年控制器/剂),它不排队任何建立和错误与我的自定义异常说不定义从TFS返回。

我的问题:

时的$ buildServer.QueryBuildDefinitions()函数只有管理员功能?即如果一个非管理员用户帐户(如TFSSERVICE)运行它,它不能从TFS API获得数据?

时的$ buildServer.QueryBuildDefinitions()的新功能,即仅适用于2012年?

是否有这样做,将工作的另一种方式? previously,我们有我们的名字建立硬codeD - 这不是我们前进的可行方法。

<$p$p><$c$c>[void][System.Reflection.Assembly]::LoadWithPartialName(\"Microsoft.TeamFoundation.Client\")
[空] [System.Reflection.Assembly] :: LoadWithPartialName(Microsoft.TeamFoundation.Build.Client)$ SERVERNAME =HTTP:// TFS:8080 / TFS
$ TFS = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory] ​​:: GetServer($服务器名)
$ buildserver = $ tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])$ buildServer.QueryBuildDefinitions(FooProject)| {的foreach
如果($ _。的endsWith(version_1_0))
{
回声排队编译:$ _姓名
$ buildServer.QueueBuild($ buildServer.GetBuildDefinition(FooProject,$ _。名称))
        }
    }
}

编辑:删除 $ buildDefinitions = $ buildServer.QueryBuildDefinitions(FooProject)名称 $ buildServer.QueryBuildDefinitions(FooProject取而代之)|的foreach ...

版本是现在编程排队。


解决方案

该API并没有改变,我想这两种药物都使用相同的帐号。


  

$ buildDefinitions = $ buildServer.QueryBuildDefinitions(FooProject)。名称


似乎是错误的:Name属性get会抛出一个异常,一个空的结果。

TFS2012 with a one 2010 build controller with one 2010 build agent. Also have one 2012 build controller with multiple 2012 build agents.

We have multiple builds for multiple versions of our software. The builds are named according to a convention e.g. Foo_version_1_0 and Foo_version_2_0.

When I run this code on my local machine, all the builds are queued. When I run this code manually on a 2012 build agent, the builds are queued. When I run this code manually on a 2010 build agent, no builds are queued. When the code is executed as part of a triggered build in TFS (either on the 2010 or 2012 controller/agent), it doesn't queue any builds and errors out with my custom exception saying no definitions returned from TFS.

My questions:

Is the $buildServer.QueryBuildDefinitions() function an administrator function only? I.e. if a non-admin user account (like TFSService) runs it, it won't be able to get the data from the TFS api?

Is the $buildServer.QueryBuildDefinitions() a new function that is only available in 2012?

Is there another way of doing this that will work? Previously, we had all our build names hard coded - this is not a viable way forward for us.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")

$serverName="http://tfs:8080/tfs"
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
$buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])

$buildServer.QueryBuildDefinitions("FooProject") | foreach {
if ($_.EndsWith("version_1_0"))
{
echo "Queueing build: $_.Name"
$buildServer.QueueBuild($buildServer.GetBuildDefinition("FooProject",$_.Name))
        }
    }
}

Edit: removed $buildDefinitions = $buildServer.QueryBuildDefinitions("FooProject").Name, replaced it with $buildServer.QueryBuildDefinitions("FooProject") | foreach...

Builds are now queued programmatically.

解决方案

The API hasn't changed, and I suppose that both agents are using the same account.

The line

$buildDefinitions = $buildServer.QueryBuildDefinitions("FooProject").Name

seems wrong: the Name property get will raise an exception for an empty result.

这篇关于排队TFS通过PowerShell的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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