1
var failed = Client.FailedBuildsByBuildConfigId(buildConfig.Id).ToString();

这就是创建列表的方式。我正在使用 TeamCity Sharp,我是新手。返回的是:

System.Collections.Generic.List`1[TeamCitySharp.DomainEntities.Build]

我想在列表中找到字符串“FAILURE”。我该怎么做呢?

4

2 回答 2

3

尝试:

bool failed = Client.FailedBuildsByBuildConfigId(buildConfig.Id).Any(b => b.ToString().Contains("FAILURE"))

我不知道该类的输出,但如果ToString()实际上不返回Status(或 StatusText),请改为执行以下操作之一:

//examine Status field
bool failed = Client.FailedBuildsByBuildConfigId(buildConfig.Id).Any(b => b.Status.Contains("FAILURE"))

或者

//examine StatusText field
bool failed = Client.FailedBuildsByBuildConfigId(buildConfig.Id).Any(b => b.StatusText.Contains("FAILURE"))
于 2012-05-11T14:30:18.417 回答
1

当您使用Client.FailedBuildsByBuildConfigId(buildConfig.Id).ToString()它时,它会返回从 FailedBuildsByBuildConfigId 返回的对象类型的名称。

尝试

var failed = Client.FailedBuildsByBuildConfigId(buildConfig.Id).Where(b => b.Status == "FAILED");
于 2012-05-11T14:34:00.707 回答