From 8f4cfb67da9f735d6a96c0a6e44884a2f0d26aa3 Mon Sep 17 00:00:00 2001 From: lichengjun Date: Mon, 30 Aug 2021 06:52:02 +0000 Subject: [PATCH] * Add Sync MR from GitLab API to Zentao database, default time 5 minutes to execute once. --- db/update15.3.sql | 3 +++ module/install/lang/zh-cn.php | 1 + module/mr/control.php | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/db/update15.3.sql b/db/update15.3.sql index 743ccea4e4..6b8dd5c83c 100644 --- a/db/update15.3.sql +++ b/db/update15.3.sql @@ -1 +1,4 @@ ALTER TABLE `zt_testtask` ADD `realFinishedDate` datetime NOT NULL AFTER `end`; + +INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES +('*/5', '*', '*', '*', '*', 'moduleName=mr&methodName=syncMR', '定时同步GitLab合并数据到禅道数据库', 'zentao', 1, 'normal', '0000-00-00 00:00:00'); diff --git a/module/install/lang/zh-cn.php b/module/install/lang/zh-cn.php index 988abbab0d..3e056fff4a 100644 --- a/module/install/lang/zh-cn.php +++ b/module/install/lang/zh-cn.php @@ -169,6 +169,7 @@ $lang->install->cronList['moduleName=todo&methodName=createCycle'] = '生 $lang->install->cronList['moduleName=ci&methodName=initQueue'] = '创建周期性任务'; $lang->install->cronList['moduleName=ci&methodName=checkCompileStatus'] = '同步Jenkins任务状态'; $lang->install->cronList['moduleName=ci&methodName=exec'] = '执行Jenkins任务'; +$lang->install->cronList['moduleName=mr&methodName=syncMR'] = '定时同步GitLabMR信息'; $lang->install->success = "安装成功"; $lang->install->login = '登录禅道管理系统'; diff --git a/module/mr/control.php b/module/mr/control.php index cf3cfe938d..5acb340fa0 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -131,6 +131,25 @@ class mr extends control $this->display(); } + /** + * Crontab sync MR from GitLab API to Zentao database, default time 5 minutes to execute once. + * + * @access public + * @return void + */ + public function syncMR() + { + $this->mr->getList(); + + if(dao::isError()) + { + echo json_encode(dao::getError()); + return true; + } + + echo 'success'; + } + /** * AJAX: Get MR target projects. *