forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoRemoveBuilds.php
58 lines (48 loc) · 1.73 KB
/
autoRemoveBuilds.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
<?php
/*=========================================================================
Program: CDash - Cross-Platform Dashboard System
Module: $Id$
Language: PHP
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
/** Adding some PHP include path */
$path = dirname(__FILE__);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
include("cdash/config.php");
require_once("cdash/pdo.php");
require_once("cdash/autoremove.php");
if($argc != 2)
{
print "Usage: php $argv[0] <project_name>\n";
print "Or: php $argv[0] all\n";
return -1;
}
$db = pdo_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
pdo_select_db("$CDASH_DB_NAME",$db);
set_time_limit(0);
$projectname=$argv[1];
print "removing builds for $projectname \n";
$sql = " WHERE name='".$projectname."'";
if($projectname == "all")
{
$sql="";
}
$project = pdo_query("SELECT id,autoremovetimeframe,autoremovemaxbuilds FROM project".$sql);
if(!$project)
{
add_last_sql_error('autoRemoveBuilds');
return false;
}
while($project_array = pdo_fetch_array($project))
{
removeFirstBuilds($project_array['id'],$project_array['autoremovetimeframe'],$project_array['autoremovemaxbuilds'], true); // force the autoremove
removeBuildsGroupwise($project_array['id'],$project_array['autoremovemaxbuilds'],true); // force the autoremove
}
return 0;
?>