有Cruise Control .NET的API吗? [英] Is there an API for Cruise Control .NET?

查看:155
本文介绍了有Cruise Control .NET的API吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可以使用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的文档或如何使用它的示例。 / p>

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。我以前从他们的SVN存储库下载了代码(注意:根据下面的URL,它现在托管在 github.com )修复一个bug(上次构建时间列的工作方式 - 这是修复,但在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.

储存库网址是 https://github.com/ccnet/CruiseControl.NET

I只是更新了我的本地副本,并有一个mooch通过和一个可能的候选人你想要的是 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.

使用远程程序集获取每个项目的状态/强制构建

Using the Remote assembly to obtain the status of each project / force a build


  • 从git编译来源

  • 建立新的控制台应用程式

  • 添加对 Thoughtworks.CruiseControl.Remote NetReflector 的引用(两者都将在\bin Remote 项目的目录

  • 将以下代码添加到控制台应用程序

  • Compile the source from git
  • Create a new console application
  • Add a reference to Thoughtworks.CruiseControl.Remote and NetReflector (both will be in the \bin directory for the Remote 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:


ProjectName - 成功

ProjectName - Success

要强制构建,您将进行以下调用:

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

Content-Type:application / x-www-form-urlencoded

主机:192.168.100.180

Content-长度: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 = >

ForceBuild=true&projectName=PROJECT_NAME&serverName=local

这篇关于有Cruise Control .NET的API吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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