我想将动态参数传递给ForceBuild。但CruiseControl.NET似乎忽略了这些参数,至少有两个客户端 - CruiseServerHttpClient和CruiseServerRemotingClient。此处ForceBuildClient2()
和ForceBuildClient3()
强制构建,但CruiseControl会忽略参数。
而第三个客户端 - CruiseServerClient()抛出错误。此处ForceBuildClient1()
会引发异常 - “The remote server returned an error: (500) Internal Server Error.
”
请帮我解决这个问题。代码如下: -
void ForceBuildWithParameters
{
try
{
List<NameValuePair> parameters = new List<NameValuePair>();
NameValuePair nvPair = new NameValuePair();
nvPair.Name = "BetaLinkVersion";
nvPair.Value = "TTS_WB_Suite_14.1.23";
parameters.Add(nvPair);
NameValuePair nvPair2 = new NameValuePair();
nvPair2.Name = "SmartVersion";
nvPair2.Value = "smtone_smtone";
parameters.Add(nvPair2);
bool bAsRequest = false;
var request = new IntegrationRequest(BuildCondition.ForceBuild, "WIN-O1GHG0JM8MC", "balasubramaniam.ramasamy");
request.BuildValues.Add("BetaLinkVersion", "TTS_WB_Suite_14.1.23");
request.BuildValues.Add("SmartVersion", "smtone_smtone");
ForceBuildClient1(parameters, bAsRequest, request); // Not working
ForceBuildClient2(parameters, bAsRequest, request);
ForceBuildClient3(parameters, bAsRequest, request);
}
catch (Exception)
{
throw;
}
}
private void ForceBuildClient1(List<NameValuePair> parameters, bool bAsRequest, IntegrationRequest request)
{
HttpConnection connection = new HttpConnection("http://localhost/ccnet");
CruiseServerClient client = new CruiseServerClient(connection);
if (!bAsRequest)
client.ForceBuild("Package Beta Link", parameters); // Not working
else
client.Request("Package Beta Link", request); // Not working
}
private void ForceBuildClient2(List<NameValuePair> parameters, bool bAsRequest, IntegrationRequest request)
{
CruiseServerRemotingClient client = new CruiseServerRemotingClient("tcp://t1devbuild.int.thomsonreuters.com:21234/CruiseManager.rem");
if (!bAsRequest)
client.ForceBuild("Package Beta Link", parameters);
else
client.Request("Package Beta Link", request);
}
private void ForceBuildClient3(List<NameValuePair> parameters, bool bAsRequest, IntegrationRequest request)
{
var client = new CruiseServerHttpClient(string.Format("http://{0}/ccnet/", "t1devbuild.int.thomsonreuters.com"));
if(!bAsRequest)
client.ForceBuild("Package Beta Link", parameters);
else
client.Request("Package Beta Link", request);
}