Cruise的API简介--Properties篇

Cuise提供了一些Restful Url,方便用户来使用Cruise。目前这些Restful Url覆盖三个方面

(一)关于Artifacts的操作

  例如查看某个job有哪些Artifacts,以及通过API下载这些Artifacts,向某个已完成的Job上传某些文件。

(二)关于Properties的操作

  例如查看某个job有哪些属性,它们的值是什么,以及为某个job增加一个属性,做为一个Comment等。

(三)关于配置管理的操作

  目前,Cruise可以通过Restful API增加Pipeline。

 

——————————————————————————————————

Cruise为JOB提供的标准属性包括:

  • cruise_agent -- 该JOB是在该Agent上运行的
  • cruise_job_duration -- 运行该JOB所用的总时间
  • cruise_job_result -- 运行的结果(passed or failed)
  • cruise_pipeline_label -- 该JOB所在Pipeline的标签
  • cruise_timestamp_01_scheduled -- 该JOB被scheduled的时间
  • cruise_timestamp_02_assigned -- 该JOB被分配给agent的时间
  • cruise_timestamp_03_preparing -- 该JOB开始checking out source code 的时间
  • cruise_timestamp_04_building -- 该JOB开始执行的时间
  • cruise_timestamp_05_completing -- 该JOB执行完成,开始发送Artifacts的时间
  • cruise_timestamp_06_completed -- 该JOB在Agent上完全结束的时间

下面是相应API的格式

Parameters
Method URL format HTTPVerb Explanation
list http://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job] GET 列出属于该pipeline下该stage下这个job的所有属性(html格式)
list http://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job].csv GET 列出属于该pipeline下该stage下这个job的所有属性(CSV格式)
list http://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job].json GET 列出属于该pipeline下该stage下这个job的所有属性(json格式)
show http://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job]/[propertyname] GET 得到某个属性具体的值.
create http://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job]?[propertyname]=[propertyvalue] POST 创建一个属性并赋予其值.

 

其中

  • [ label]可以是 'latest', 'lastgood', 'history' ,也可以是某个具体的label。
  • 名字和Label是大小写敏感的,所以要与配置文件中的完全一样。

示例:(所以示例基于以下假设信息)

  • 使用Curl(a command line tool for rowansferring files with URL syntax)作为演示工具。
  • Cruise的URL是 http://cruiseserver.com:8153/ .
  • 需要登录,用户名是 jez ,密码是 badger

该Pipeline的配置如下所示:

    
    
    
    
  1.       <pipeline name="foo" labeltemplete="foo-1.0-${COUNT}">
  2.          <material>
  3.                <svn url="...."/>
  4.          </material>
  5.          <stage name="DEV">
  6.            <job name="UnitTest">
  7.            <tasks>
  8.               <ant target="ut"/>
  9.            </tasks>
  10.                  <artifacts>
  11.                     <artifact  src="coverage" dest="coveragereport.html"/>         
  12.            </artifacts>
  13.          </job>
  14.          </stage>
  15.          <stage name="UATest">
  16.            <job name="UAT">
  17.            <tasks>
  18.               <ant target="all-UAT"/>
  19.            </tasks>
  20.                  <artifacts>
  21.                     <artifact  src="report" dest="UAreport.html"/>
  22.                     <artifact  src="target" dest="pkg/foo.war"/>
  23.            </artifacts>
  24.          </job>
  25.          </stage>
  26.       </pipeline>

得到最后一次成功的Job的属性值列表并以Json格式返回,可以使用下面的命令

  1. curl -u jez:badger http://cruiseserver.com:8153/cruise/properties/foo/lastgood/DEV/UnitTest.json 

得到Label为‘foo-1.0-1243’的UnitTest的属性值列表并以csv格式返回,可以使用下面的命令

  1. curl -u jez:badger http://cruiseserver.com:8153/cruise/properties/foo/foo-1.0-1243/DEV/UnitTest.csv

得到所有的UnitTest的属性值,可以使用下面的命令

  1. curl -u jez:badger http://cruiseserver.com:8153/cruise/properties/foo/history/DEV/UnitTest.csv

得到Label为‘foo-1.0-1243’的UnitTest下属性'Cruise_agent'的值,可以使用下面的命令

  1. curl -u jez:badger http://cruiseserver.com:8153/cruise/properties/foo/foo-1.0-1243/DEV/UnitTest/Cruise_agent

如果要定义一个属性,名为myproperty,值为‘showcase for I29’,可以使用下面的命令

    
    
    
    
  1. curl -u jez:badger -d "value=Showcase for I29" http://10.18.3.168:8153/cruise/properties/foo/latest/DEV/UnitTest/myproperty

你可能感兴趣的:(api,server,properties,配置管理,url,csv)