是否有用于 Cruise Control .NET 的 API? [英] Is there an API for Cruise Control .NET?
问题描述
是否有可以与 Cruise Control .NET (ccnet) 一起使用的 API 来查询服务器,例如获取各种构建的状态?
Is there an API I can use with Cruise Control .NET (ccnet) to query the server, for example to get the status of various builds?
我注意到 ccnet 托盘应用程序中有一些用于连接的选项,但我找不到任何关于服务 API 的文档或如何使用它的示例.
I have noticed that there are a few options in the ccnet tray application for connecting but I cannot find any documentation of the service API or examples of how to consume it.
推荐答案
当然有一个 API,因为 Tray 应用程序使用它.我以前从他们的 SVN 存储库下载了代码(注意:按照下面的 URL,它现在托管在 github.com
上)以修复错误(方式上次构建时间"列有效 - 已修复,但在 1.5 版本中有所下降),这可能是一个不错的起点.
There's certainly an API as the Tray application uses it. I've downloaded the code from their SVN repository previously (NOTE: as per the URL below, it's now hosted on github.com
) to fix a bug (the way the "Last Build Time" column works - which was fixed, but regressed in the 1.5 release), and that'd probably be a good place to start.
存储库 url 是 https://github.com/ccnet/CruiseControl.NET
.
The repository url is https://github.com/ccnet/CruiseControl.NET
.
我刚刚更新了我的本地副本,并通过了一个可能的候选对象是 Remote
项目中的 CruiseServerHttpClient
类.
I've just updated my local copy and had a mooch through and a likely candidate for what you want is the CruiseServerHttpClient
class in the Remote
project.
使用Remote
程序集获取每个项目的状态/强制构建
Using the Remote
assembly to obtain the status of each project / force a build
- 从 git 编译源代码
- 创建一个新的控制台应用程序
- 添加对
Thoughtworks.CruiseControl.Remote
和NetReflector
的引用(两者都将位于Remote
项目的 \bin 目录中) - 将以下代码添加到您的控制台应用程序
- Compile the source from git
- Create a new console application
- Add a reference to
Thoughtworks.CruiseControl.Remote
andNetReflector
(both will be in the \bin directory for theRemote
project) - Add the following code to your console application
控制台应用程序代码:
using System;
using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Remote;
using ThoughtWorks.CruiseControl.Remote.Messages;
namespace CruiseControlInterface
{
class Program
{
static void Main(string[] args)
{
var ipAddressOrHostNameOfCCServer = ""; // Complete this value
var client = new CruiseServerHttpClient(
string.Format("http://{0}/ccnet/",ipAddressOrHostNameOfCCServer));
foreach (var projectStatus in client.GetProjectStatus())
{
Console.WriteLine("{0} - {1}", projectStatus.Name, projectStatus.BuildStatus);
}
}
}
}
对于每个项目,您将获得类似于以下内容的输出:
For each project you'll get output similar to:
项目名称 - 成功
要强制构建,您需要进行以下调用:
To force a build, you'd make the following call:
client.Request("PROJECT_NAME", new IntegrationRequest(BuildCondition.ForceBuild, "YOUR_MACHINE_NAME", "YOUR_USER_NAME"));
在幕后,这会导致发出 HTTP 请求,其中包括:
Under the hood this results in a HTTP request being made that consists of:
POST http://CC_SERVER_NAME/ccnet/ViewFarmReport.aspx HTTP/1.1
内容类型:应用程序/x-www-form-urlencoded
主机:192.168.100.180
内容长度:64
预期:100-继续
POST http://CC_SERVER_NAME/ccnet/ViewFarmReport.aspx HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: 192.168.100.180
Content-Length: 64
Expect: 100-continue
ForceBuild=true&projectName=PROJECT_NAME&serverName=local
ForceBuild=true&projectName=PROJECT_NAME&serverName=local
这篇关于是否有用于 Cruise Control .NET 的 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!