add job into zt_cron table to check citask status every 5 mins

This commit is contained in:
aaronchen2k
2020-01-15 13:43:10 +08:00
parent af258f8fdf
commit 933ebacfb5
4 changed files with 97 additions and 105 deletions
+1 -11
View File
@@ -131,17 +131,8 @@ fi
echo $deletelog > $basePath/deletelog.sh
echo "deletelog.sh ok"
# check jenkins task status.
if [ $requestType == 'PATH_INFO' ]; then
checkCibuild="$phpcli $basePath/ztcli '$pmsRoot/ci-checkCibuild'";
else
checkCibuild="$phpcli $basePath/ztcli '$pmsRoot/index.php?m=ci&f=checkCibuild'";
fi
echo $checkCibuild > $basePath/checkcibuild.sh
echo "checkcibuild.sh ok"
# cron
if [ ! -d "$basePath/cron" ]; then
if [ ! -d "$basePath/cron" ]; then
mkdir $basePath/cron
fi
echo "# system cron." > $basePath/cron/sys.cron
@@ -155,7 +146,6 @@ echo "1-59/5 * * * * $basePath/sendmail.sh # async send mail
echo "1-59/5 * * * * $basePath/sendwebhook.sh # async send webhook." >> $basePath/cron/sys.cron
echo "1 1 * * * $basePath/createcycle.sh # create cycle todo." >> $basePath/cron/sys.cron
echo "30 1 * * * $basePath/deletelog.sh # delete log." >> $basePath/cron/sys.cron
echo "1-59/3 * * * * $basePath/checkcibuild.sh # check ci build status." >> $basePath/cron/sys.cron
cron="$phpcli $basePath/php/crond.php"
echo $cron > $basePath/cron.sh
echo "cron.sh ok"
+80
View File
@@ -0,0 +1,80 @@
ALTER TABLE `zt_repo`
ADD COLUMN `credential` MEDIUMINT(8) NULL AFTER `password`;
ALTER TABLE `zt_repo`
ADD COLUMN `desc` TEXT NULL AFTER `lastSync`;
CREATE TABLE `zt_credentials` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(10) NOT NULL DEFAULT 'account',
`name` varchar(50) NOT NULL,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`publicKey` text,
`privateKey` text,
`passphrase` varchar(20) DEFAULT NULL,
`desc` text NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
`token` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_jenkins` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`username` varchar(255) DEFAULT NULL,
`serviceUrl` varchar(255) DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`desc` text NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
`credential` mediumint(8) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_citask` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`repo` mediumint(8) unsigned NOT NULL,
`jenkins` mediumint(8) unsigned NOT NULL,
`jenkinsTask` varchar(500) NOT NULL,
`buildType` varchar(255) NOT NULL,
`triggerType` varchar(255) NOT NULL,
`scheduleType` varchar(255) NOT NULL,
`cornExpression` varchar(255) DEFAULT NULL,
`scheduleDay` varchar(255) DEFAULT NULL,
`scheduleTime` varchar(255) DEFAULT NULL,
`scheduleInterval` mediumint(8) DEFAULT NULL,
`tagKeywords` varchar(255) DEFAULT NULL,
`commentKeywords` varchar(255) DEFAULT NULL,
`desc` text,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_cibuild` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`citask` mediumint(8) unsigned NOT NULL,
`status` varchar(255) NOT NULL,
`logs` text,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`updateDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES
('*/5', '*', '*', '*', '*', 'moduleName=ci&methodName=checkCibuild', '同步Jenkins任务状态', 'zentao', 0, 'stop', '0000-00-00 00:00:00');
+1 -79
View File
@@ -3450,82 +3450,4 @@ INSERT INTO `zt_grouppriv` (`group`, `module`, `method`) VALUES
(11, 'user', 'testTask'),
(11, 'user', 'todo'),
(11, 'user', 'view'),
(12, 'my', 'limited');
ALTER TABLE `zentao_zhonghe`.`zt_repo`
ADD COLUMN `credential` MEDIUMINT(8) NULL AFTER `password`;
ALTER TABLE `zentao_zhonghe`.`zt_repo`
ADD COLUMN `desc` TEXT NULL AFTER `lastSync`;
CREATE TABLE `zt_credentials` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(10) NOT NULL DEFAULT 'account',
`name` varchar(50) NOT NULL,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`publicKey` text,
`privateKey` text,
`passphrase` varchar(20) DEFAULT NULL,
`desc` text NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
`token` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_jenkins` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`username` varchar(255) DEFAULT NULL,
`serviceUrl` varchar(255) DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`desc` text NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
`credential` mediumint(8) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_citask` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`repo` mediumint(8) unsigned NOT NULL,
`jenkins` mediumint(8) unsigned NOT NULL,
`jenkinsTask` varchar(500) NOT NULL,
`buildType` varchar(255) NOT NULL,
`triggerType` varchar(255) NOT NULL,
`scheduleType` varchar(255) NOT NULL,
`cornExpression` varchar(255) DEFAULT NULL,
`scheduleDay` varchar(255) DEFAULT NULL,
`scheduleTime` varchar(255) DEFAULT NULL,
`scheduleInterval` mediumint(8) DEFAULT NULL,
`tagKeywords` varchar(255) DEFAULT NULL,
`commentKeywords` varchar(255) DEFAULT NULL,
`desc` text,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`editedBy` varchar(30) NOT NULL,
`editedDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
CREATE TABLE `zt_cibuild` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`citask` mediumint(8) unsigned NOT NULL,
`status` varchar(255) NOT NULL,
`logs` text,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
`updateDate` datetime NOT NULL,
`deleted` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
(12, 'my', 'limited');
+15 -15
View File
@@ -474,6 +474,21 @@ class ci extends control
$this->send(array('result' => 'success'));
}
/**
* sync repo from remote.
*
* @param int $repoID
* @access public
* @return void
*/
public function syncRepo($repoID = 0)
{
$this->dao->update(TABLE_REPO)->set('synced')->eq(0)->where('id')->eq($repoID)->exec();
$link = $this->ci->createLink('showSyncComment', "repoID=$repoID&needPull=true");
$this->send(array('result' => 'success', 'locate' => $link));
}
/**
* browse branches.
*
@@ -493,21 +508,6 @@ class ci extends control
$this->display();
}
/**
* sync repo from remote.
*
* @param int $repoID
* @access public
* @return void
*/
public function syncRepo($repoID = 0)
{
$this->dao->update(TABLE_REPO)->set('synced')->eq(0)->where('id')->eq($repoID)->exec();
$link = $this->ci->createLink('showSyncComment', "repoID=$repoID&needPull=true");
$this->send(array('result' => 'success', 'locate' => $link));
}
/**
* watch branch.
*