Cruise的API简介--Properties篇

本文介绍如何利用Cruise提供的RESTful API进行配置管理和操作Artifacts及Properties。涵盖增加Pipeline、获取作业属性等操作,并提供了详细的API调用示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
MethodURL formatHTTPVerbExplanation
listhttp://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job]GET列出属于该pipeline下该stage下这个job的所有属性(html格式)
listhttp://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job].csvGET列出属于该pipeline下该stage下这个job的所有属性(CSV格式)
listhttp://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job].jsonGET列出属于该pipeline下该stage下这个job的所有属性(json格式)
showhttp://[server]/cruise/properties/[pipeline]/[label]/[stage]/[job]/[propertyname]GET得到某个属性具体的值.
createhttp://[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值