3 * Copyright 2011, Franck Villaume - Capgemini
4 * Copyright 2012, Franck Villaume - TrivialDev
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 * main cronjob for scmhook plugin
26 require dirname(__FILE__).'/../../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'include/cron_utils.php';
29 require_once $gfplugins.'scmhook/common/scmhookPlugin.class.php';
31 // if you want debug output, uncomment the verbose variable.
37 // get the list of project to be updated
38 $res = db_query_params('SELECT groups.group_id, groups.scm_box, plugin_scmhook.hooks
39 FROM groups, plugin_scmhook
40 WHERE groups.status = $1
41 AND plugin_scmhook.id_group = groups.group_id
42 AND plugin_scmhook.need_update = $2
43 AND groups.use_scm = $3',
47 cron_debug("FATAL Database Query Failed: " . db_error());
50 $scmhookPlugin = new scmhookPlugin;
51 while ($row = db_fetch_array($res)) {
52 $group_id = $row['group_id'];
53 $scm_box = $row['scm_box'];
55 // find the scm type of the project
56 $listScm = $scmhookPlugin->getListLibraryScm();
57 $group = group_get_object($group_id);
58 for ($i = 0; $i < count($listScm); $i++) {
59 if ($group->usesPlugin($listScm[$i])) {
60 $scmtype = $listScm[$i];
65 // call the right cronjob in the library
68 cron_debug("INFO start updating hooks for project ".$group->getUnixName());
69 require_once $gfplugins.'scmhook/library/'.$scmtype.'/cronjobs/updateScmRepo.php';
70 global $svndir_prefix;
71 $scmsvncronjob = new ScmSvnUpdateScmRepo();
73 $params['group_id'] = $group_id;
74 $params['hooksString'] = $row['hooks'];
75 $params['scm_root'] = forge_get_config('repos_path', 'scmsvn') . '/' . $group->getUnixName();
76 if ($scmsvncronjob->updateScmRepo($params)) {
77 $res = db_query_params('UPDATE plugin_scmhook set need_update = $1 where id_group = $2', array(0, $group_id));
85 cron_debug("INFO start updating hooks for project ".$group->getUnixName());
86 require_once $gfplugins.'scmhook/library/'.$scmtype.'/cronjobs/updateScmRepo.php';
87 $scmhgcronjob = new ScmHgUpdateScmRepo();
89 $params['group_id'] = $group_id;
90 $params['hooksString'] = $row['hooks'];
91 $params['scm_root'] = forge_get_config('repos_path', 'scmhg') . '/' . $group->getUnixName();
92 if ($scmhgcronjob->updateScmRepo($params)) {
93 $res = db_query_params('UPDATE plugin_scmhook set need_update = $1 where id_group = $2', array(0, $group_id));
101 cron_debug("WARNING No scm plugin found for this project ".$group->getUnixName()." or no cronjobs for this type");
102 $returnvalue = false;
108 cron_debug("INFO hooks updated for project ".$group->getUnixName());
110 cron_debug("ERROR Unable to update hooks for project ".$group->getUnixName());
114 cron_debug("INFO end of updateScmRepo main cronjob");