-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamcity.php
70 lines (52 loc) · 1.85 KB
/
teamcity.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
// SICKHEAD PROPRIETARY INFORMATION
//
// This software is supplied under the terms of a license agreement
// or nondisclosure agreement and may not be copied or disclosed
// except in accordance with the terms of that agreement.
//
// Copyright (c) Sickhead Games, LLC
// All Rights Reserved
// www.sickheadgames.com
include 'config.inc';
function GetXmlContent($url)
{
global $wallboard_config;
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode($wallboard_config["teamcity-login"]),
'timeout' => 60,
)
));
return simplexml_load_string( file_get_contents($url, false, $context) );
}
function ParseProjects()
{
global $wallboard_config;
$projects = GetXmlContent($wallboard_config["teamcity-url"] . "httpAuth/app/rest/projects/");
$results = array();
foreach($projects->children() as $proj)
{
$results[] = array('name' => (string)$proj['name'], 'id' => (string)$proj['id'], 'builds' => ParseBuilds((string)$proj['id']));
}
return json_encode($results);
}
function ParseBuilds($projectId)
{
global $wallboard_config;
$buildTypes = GetXmlContent($wallboard_config["teamcity-url"] . "httpAuth/app/rest/projects/$projectId/buildTypes");
$results = array();
foreach($buildTypes->children() as $bt)
{
$id = (string)$bt['id'];
$buildType = GetXmlContent($wallboard_config["teamcity-url"] . "httpAuth/app/rest/builds?locator=buildType:$id,running:any,count:1");
$build = $buildType->children()[0];
$status = (string)$build['status'];
if($status == "")
$status = "SUCCESS";
$results[] = array('id' => $id, 'name' => (string)$bt['name'], 'status' => $status, 'running' => (string)$build['running']);
}
return $results;
}
echo ParseProjects();
?>