Quantcast
Channel: beefycode - scm
Viewing all articles
Browse latest Browse all 5

get-buildstatus PowerShell Script

$
0
0

I just bashed out this powershell script to query the build farm status using the CC.NET server report XML page:

# get-buildstatus.ps1
$client = new-object system.net.webClient
$client.Headers.add("user-agent", "PowerShell")
$data = $client.openRead( 'http://builddashboard/ccnet/XmlServerReport.aspx' )
$reader = new-object system.io.streamReader $data
$s = $reader.readToEnd()
$data.close()
$reader.close()  
([xml]$s).CruiseControl.Projects.Project | ft;

Wicked simple - the WebClient class is used to connect to the build dashboard, and a stream reader object pulls the farm data.  The data is XML, which PowerShell considers warm butter and happily pivots and formats as a pretty table:

> get-buildstatus
name           category       activity       lastBuildStatu lastBuildLabel lastBuildTime  nextBuildTime  webUrl                                             s
----           --------       --------       -------------- -------------- -------------  -------------  ------
SuperDuo 3....                Pending        Success        SuperDuo_14890 2009-07-21T... 2009-07-21T... http://buil...
SuperDuo Sa...                Pending        Success        SuperDuo_14725 2009-06-16T... 2009-07-21T... http://buil...
SuperDuo 2....                Pending        Success        SuperDuo_14706 2009-06-09T... 2009-07-21T... http://buil...
SuperDuo 2.2                  Pending        Success        SuperDuo_14888 2009-07-21T... 2009-07-21T... http://buil...
...

Of course, if you have the PowerShell Community Extensions installed, the get-url cmdlet reduces the script to a one-liner:

# get-buildstatus.ps1
([xml](get-url 'http://builddashboard/ccnet/XmlServerReport.aspx')).CruiseControl.Projects.Project | ft;

I think I'll push this into a PowerGUI powerpack...

Super happy fun time deluxe!  (Enjoy!)


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images