diff --git a/module/git/model.php b/module/git/model.php
index ba51ca15d8..c3e3bbab77 100644
--- a/module/git/model.php
+++ b/module/git/model.php
@@ -70,15 +70,15 @@ class gitModel extends model
if(empty($this->repos)) return false;
$this->loadModel('compile');
- /* Get commit triggerType integrations by repoIdList. */
- $commitPlans = $this->loadModel('integration')->getListByTriggerType('commit', array_keys($this->repos));
+ /* Get commit triggerType jobs by repoIdList. */
+ $commitJobs = $this->loadModel('job')->getListByTriggerType('commit', array_keys($this->repos));
$commitGroup = array();
- foreach($commitPlans as $integration) $commitGroup[$integration->repo][$integration->id] = $integration;
+ foreach($commitJobs as $job) $commitGroup[$job->repo][$job->id] = $job;
- /* Get tag triggerType integrations by repoIdList. */
- $tagPlans = $this->integration->getListByTriggerType('tag', array_keys($this->repos));
+ /* Get tag triggerType jobs by repoIdList. */
+ $tagJobs = $this->job->getListByTriggerType('tag', array_keys($this->repos));
$tagGroup = array();
- foreach($tagPlans as $integration) $tagGroup[$integration->repo][$integration->id] = $integration;
+ foreach($tagJobs as $job) $tagGroup[$job->repo][$job->id] = $job;
foreach($this->repos as $repoID => $repo)
{
@@ -126,12 +126,12 @@ class gitModel extends model
}
/* Create compile by comment. */
- $integrations = zget($commitGroup, $repoID, array());
- foreach($integrations as $integration)
+ $jobs = zget($commitGroup, $repoID, array());
+ foreach($jobs as $job)
{
- foreach(explode(',', $integration->comment) as $comment)
+ foreach(explode(',', $job->comment) as $comment)
{
- if(strpos($log->msg, $comment) !== false) $this->compile->createByIntegration($integration->id);
+ if(strpos($log->msg, $comment) !== false) $this->compile->createByJob($job->id);
}
}
$version = $this->repo->saveOneCommit($repoID, $log, $version, $branch);
@@ -145,16 +145,16 @@ class gitModel extends model
$this->printLog("\n\nrepo #" . $repo->id . ': ' . $repo->path . " finished");
// Create compile by tag.
- $integrations = zget($tagGroup, $repoID, array());
- foreach($integrations as $integration)
+ $jobs = zget($tagGroup, $repoID, array());
+ foreach($jobs as $job)
{
$tags = $this->getRepoTags($repo);
end($tags);
$lastTag = current($tags);
- if($lastTag != $integration->lastTag)
+ if($lastTag != $job->lastTag)
{
- $this->compile->createByIntegration($integration->id, $lastTag, 'tag');
- $this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($integration->id)->exec();
+ $this->compile->createByJob($job->id, $lastTag, 'tag');
+ $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec();
}
}
}
diff --git a/module/integration/config.php b/module/integration/config.php
deleted file mode 100644
index 1f185e342a..0000000000
--- a/module/integration/config.php
+++ /dev/null
@@ -1,6 +0,0 @@
-integration = new stdclass();
-$config->integration->create = new stdclass();
-$config->integration->edit = new stdclass();
-$config->integration->create->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
-$config->integration->edit->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
diff --git a/module/integration/lang/en.php b/module/integration/lang/en.php
deleted file mode 100644
index 5e022c6d1c..0000000000
--- a/module/integration/lang/en.php
+++ /dev/null
@@ -1,38 +0,0 @@
-integration->common = 'Integration';
-$lang->integration->browse = 'Browse Integration';
-$lang->integration->create = 'Create Integration';
-$lang->integration->edit = 'Edit Integration';
-$lang->integration->exec = 'Execute Integration';
-$lang->integration->delete = 'Delete Integration';
-$lang->integration->confirmDelete = 'Do you want to delete this integration?';
-$lang->integration->dirChange = 'Directory Changed';
-$lang->integration->buildTag = 'Build Tag';
-
-$lang->integration->id = 'ID';
-$lang->integration->name = 'Name';
-$lang->integration->repo = 'Repo';
-$lang->integration->svnDir = 'SVN Tag Watch Path';
-$lang->integration->jenkins = 'Jenkins';
-$lang->integration->jkHost = 'Jenkins Server';
-$lang->integration->buildType = 'Build Type';
-$lang->integration->jkJob = 'Jenkins Task';
-$lang->integration->triggerType = 'Trigger';
-$lang->integration->atDay = 'Custom Days';
-$lang->integration->atTime = 'At Time';
-$lang->integration->lastStatus = 'Last Status';
-$lang->integration->lastExec = 'Last Executed';
-$lang->integration->comment = 'Match Keywords';
-
-$lang->integration->example = 'e.g.';
-$lang->integration->commitEx = "Used to match the keywords used to create a compile. Multiple keywords are separated by ','";
-$lang->integration->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
-$lang->integration->sendExec = 'Send execute request success.';
-
-$lang->integration->buildTypeList['build'] = 'Only Build';
-$lang->integration->buildTypeList['buildAndDeploy'] = 'Build And Deploy';
-$lang->integration->buildTypeList['buildAndTest'] = 'Build And Test';
-
-$lang->integration->triggerTypeList['tag'] = 'Tag';
-$lang->integration->triggerTypeList['commit'] = 'Code Commit';
-$lang->integration->triggerTypeList['schedule'] = 'Schedule';
diff --git a/module/integration/lang/zh-cn.php b/module/integration/lang/zh-cn.php
deleted file mode 100644
index 9a374e37b9..0000000000
--- a/module/integration/lang/zh-cn.php
+++ /dev/null
@@ -1,38 +0,0 @@
-integration->common = '构建计划';
-$lang->integration->browse = '浏览构建计划';
-$lang->integration->create = '创建构建计划';
-$lang->integration->edit = '编辑构建计划';
-$lang->integration->exec = '执行构建';
-$lang->integration->delete = '删除构建计划';
-$lang->integration->confirmDelete = '确认删除该构建计划吗?';
-$lang->integration->dirChange = '目录改动';
-$lang->integration->buildTag = '打标签';
-
-$lang->integration->id = 'ID';
-$lang->integration->name = '名称';
-$lang->integration->repo = '代码库';
-$lang->integration->svnDir = 'SVN监控路径';
-$lang->integration->jenkins = 'Jenkins';
-$lang->integration->jkHost = 'Jenkins服务器';
-$lang->integration->buildType = '构建类型';
-$lang->integration->jkJob = 'Jenkins任务';
-$lang->integration->triggerType = '触发方式';
-$lang->integration->atDay = '自定义日期';
-$lang->integration->atTime = '执行时间';
-$lang->integration->lastStatus = '最后执行状态';
-$lang->integration->lastExec = '最后执行时间';
-$lang->integration->comment = '匹配关键字';
-
-$lang->integration->example = '举例';
-$lang->integration->commitEx = "用于匹配创建构建任务的关键字,多个关键字用','分割";
-$lang->integration->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
-$lang->integration->sendExec = '发送执行请求成功!';
-
-$lang->integration->buildTypeList['build'] = '仅构建';
-$lang->integration->buildTypeList['buildAndDeploy'] = '构建部署';
-$lang->integration->buildTypeList['buildAndTest'] = '构建测试';
-
-$lang->integration->triggerTypeList['tag'] = '打标签';
-$lang->integration->triggerTypeList['commit'] = '提交注释包含关键字';
-$lang->integration->triggerTypeList['schedule'] = '定时计划';
diff --git a/module/integration/view/browse.html.php b/module/integration/view/browse.html.php
deleted file mode 100644
index cee419d6d6..0000000000
--- a/module/integration/view/browse.html.php
+++ /dev/null
@@ -1,87 +0,0 @@
-
- * @package ci
- * @version $Id$
- * @link http://www.zentao.net
- */
-?>
-
-
-
- createLink('integration', 'browse'), "{$lang->ci->plan}", '', "class='btn btn-link btn-active-text'");?>
- createLink('compile', 'browse'), "{$lang->ci->history}", '', "class='btn btn-link'");?>
-
-
- " . $lang->integration->create, '', "class='btn btn-primary'");?>
-
-
-
-
diff --git a/module/job/config.php b/module/job/config.php
new file mode 100644
index 0000000000..fbca68a83a
--- /dev/null
+++ b/module/job/config.php
@@ -0,0 +1,6 @@
+job = new stdclass();
+$config->job->create = new stdclass();
+$config->job->edit = new stdclass();
+$config->job->create->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
+$config->job->edit->requiredFields = 'name,repo,jkHost,jkJob,triggerType';
diff --git a/module/integration/control.php b/module/job/control.php
similarity index 70%
rename from module/integration/control.php
rename to module/job/control.php
index 465cb97a19..cf2fe17c49 100644
--- a/module/integration/control.php
+++ b/module/job/control.php
@@ -1,15 +1,15 @@
- * @package integration
+ * @package job
* @version $Id$
* @link http://www.zentao.net
*/
-class integration extends control
+class job extends control
{
/**
* Construct
@@ -26,7 +26,7 @@ class integration extends control
}
/**
- * Browse integration.
+ * Browse job.
*
* @param string $orderBy
* @param int $recTotal
@@ -41,11 +41,11 @@ class integration extends control
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->app->loadLang('compile');
- $this->view->jobList = $this->integration->getList($orderBy, $pager);
+ $this->view->jobList = $this->job->getList($orderBy, $pager);
- $this->view->title = $this->lang->ci->integration . $this->lang->colon . $this->lang->integration->browse;
- $this->view->position[] = $this->lang->ci->integration;
- $this->view->position[] = $this->lang->integration->browse;
+ $this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->browse;
+ $this->view->position[] = $this->lang->ci->job;
+ $this->view->position[] = $this->lang->job->browse;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
@@ -53,7 +53,7 @@ class integration extends control
}
/**
- * Create a integration.
+ * Create a job.
*
* @access public
* @return void
@@ -62,16 +62,16 @@ class integration extends control
{
if($_POST)
{
- $this->integration->create();
+ $this->job->create();
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}
$this->app->loadLang('action');
- $this->view->title = $this->lang->ci->integration . $this->lang->colon . $this->lang->integration->create;
- $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->integration);
- $this->view->position[] = $this->lang->integration->create;
+ $this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->create;
+ $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
+ $this->view->position[] = $this->lang->job->create;
$repoList = $this->loadModel('repo')->getList();
$repoPairs = array(0 => '');
@@ -90,7 +90,7 @@ class integration extends control
}
/**
- * Edit a integration.
+ * Edit a job.
*
* @param int $id
* @access public
@@ -98,17 +98,17 @@ class integration extends control
*/
public function edit($id)
{
- $job = $this->integration->getByID($id);
+ $job = $this->job->getByID($id);
if($_POST)
{
- $this->integration->update($id);
+ $this->job->update($id);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
}
- $this->view->title = $this->lang->ci->integration . $this->lang->colon . $this->lang->integration->edit;
- $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->integration);
- $this->view->position[] = $this->lang->integration->edit;
+ $this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->edit;
+ $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
+ $this->view->position[] = $this->lang->job->edit;
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
$this->view->repo = $this->loadModel('repo')->getRepoByID($job->repo);
@@ -134,7 +134,7 @@ class integration extends control
}
/**
- * Delete a integration.
+ * Delete a job.
*
* @param int $id
* @access public
@@ -142,14 +142,14 @@ class integration extends control
*/
public function delete($id, $confirm = 'no')
{
- if($confirm != 'yes') die(js::confirm($this->lang->integration->confirmDelete, inlink('delete', "integrationID=$id&confirm=yes")));
+ if($confirm != 'yes') die(js::confirm($this->lang->job->confirmDelete, inlink('delete', "jobID=$id&confirm=yes")));
- $this->integration->delete(TABLE_INTEGRATION, $id);
+ $this->job->delete(TABLE_JOB, $id);
die(js::reload('parent'));
}
/**
- * Exec a integration.
+ * Exec a job.
*
* @param int $id
* @access public
@@ -157,9 +157,11 @@ class integration extends control
*/
public function exec($id)
{
- $result = $this->integration->exec($id);
- if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
- if(!$result) $this->send(array('result' => 'fail', 'message' => 'not found'));
- die(js::alert($this->lang->integration->sendExec));
+ $status = $this->job->exec($id);
+ if(dao::isError()) die(js::error(dao::getError()));
+
+ $this->app->loadLang('compile');
+ echo js::alert(sprintf($this->lang->job->sendExec, zget($this->lang->compile->statusList, $status)));
+ die(js::reload('parent'));
}
}
diff --git a/module/integration/css/create.css b/module/job/css/create.css
similarity index 100%
rename from module/integration/css/create.css
rename to module/job/css/create.css
diff --git a/module/integration/css/edit.css b/module/job/css/edit.css
similarity index 100%
rename from module/integration/css/edit.css
rename to module/job/css/edit.css
diff --git a/module/integration/js/create.js b/module/job/js/create.js
similarity index 100%
rename from module/integration/js/create.js
rename to module/job/js/create.js
diff --git a/module/integration/js/edit.js b/module/job/js/edit.js
similarity index 100%
rename from module/integration/js/edit.js
rename to module/job/js/edit.js
diff --git a/module/job/lang/en.php b/module/job/lang/en.php
new file mode 100644
index 0000000000..a37fc4a4a9
--- /dev/null
+++ b/module/job/lang/en.php
@@ -0,0 +1,38 @@
+job->common = 'Job';
+$lang->job->browse = 'Browse Job';
+$lang->job->create = 'Create Job';
+$lang->job->edit = 'Edit Job';
+$lang->job->exec = 'Execute Job';
+$lang->job->delete = 'Delete Job';
+$lang->job->confirmDelete = 'Do you want to delete this job?';
+$lang->job->dirChange = 'Directory Changed';
+$lang->job->buildTag = 'Build Tag';
+
+$lang->job->id = 'ID';
+$lang->job->name = 'Name';
+$lang->job->repo = 'Repo';
+$lang->job->svnDir = 'SVN Tag Watch Path';
+$lang->job->jenkins = 'Jenkins';
+$lang->job->jkHost = 'Jenkins Server';
+$lang->job->buildType = 'Build Type';
+$lang->job->jkJob = 'Jenkins Task';
+$lang->job->triggerType = 'Trigger';
+$lang->job->atDay = 'Custom Days';
+$lang->job->atTime = 'At Time';
+$lang->job->lastStatus = 'Last Status';
+$lang->job->lastExec = 'Last Executed';
+$lang->job->comment = 'Match Keywords';
+
+$lang->job->example = 'e.g.';
+$lang->job->commitEx = "Used to match the keywords used to create a compile. Multiple keywords are separated by ','";
+$lang->job->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
+$lang->job->sendExec = 'Send execute request success.';
+
+$lang->job->buildTypeList['build'] = 'Only Build';
+$lang->job->buildTypeList['buildAndDeploy'] = 'Build And Deploy';
+$lang->job->buildTypeList['buildAndTest'] = 'Build And Test';
+
+$lang->job->triggerTypeList['tag'] = 'Tag';
+$lang->job->triggerTypeList['commit'] = 'Code Commit';
+$lang->job->triggerTypeList['schedule'] = 'Schedule';
diff --git a/module/job/lang/zh-cn.php b/module/job/lang/zh-cn.php
new file mode 100644
index 0000000000..6b44810294
--- /dev/null
+++ b/module/job/lang/zh-cn.php
@@ -0,0 +1,38 @@
+job->common = '构建计划';
+$lang->job->browse = '浏览构建计划';
+$lang->job->create = '创建构建计划';
+$lang->job->edit = '编辑构建计划';
+$lang->job->exec = '执行构建';
+$lang->job->delete = '删除构建计划';
+$lang->job->confirmDelete = '确认删除该构建计划吗?';
+$lang->job->dirChange = '目录改动';
+$lang->job->buildTag = '打标签';
+
+$lang->job->id = 'ID';
+$lang->job->name = '名称';
+$lang->job->repo = '代码库';
+$lang->job->svnDir = 'SVN监控路径';
+$lang->job->jenkins = 'Jenkins';
+$lang->job->jkHost = 'Jenkins服务器';
+$lang->job->buildType = '构建类型';
+$lang->job->jkJob = 'Jenkins任务';
+$lang->job->triggerType = '触发方式';
+$lang->job->atDay = '自定义日期';
+$lang->job->atTime = '执行时间';
+$lang->job->lastStatus = '最后执行状态';
+$lang->job->lastExec = '最后执行时间';
+$lang->job->comment = '匹配关键字';
+
+$lang->job->example = '举例';
+$lang->job->commitEx = "用于匹配创建构建任务的关键字,多个关键字用','分割";
+$lang->job->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
+$lang->job->sendExec = '发送执行请求成功!执行结果:%s';
+
+$lang->job->buildTypeList['build'] = '仅构建';
+$lang->job->buildTypeList['buildAndDeploy'] = '构建部署';
+$lang->job->buildTypeList['buildAndTest'] = '构建测试';
+
+$lang->job->triggerTypeList['tag'] = '打标签';
+$lang->job->triggerTypeList['commit'] = '提交注释包含关键字';
+$lang->job->triggerTypeList['schedule'] = '定时计划';
diff --git a/module/integration/model.php b/module/job/model.php
similarity index 56%
rename from module/integration/model.php
rename to module/job/model.php
index 71f8c8c613..05dcfa5c7d 100644
--- a/module/integration/model.php
+++ b/module/job/model.php
@@ -1,15 +1,15 @@
- * @package integration
+ * @package job
* @version $Id$
* @link http://www.zentao.net
*/
-class integrationModel extends model
+class jobModel extends model
{
/**
* Get by id.
@@ -20,11 +20,11 @@ class integrationModel extends model
*/
public function getByID($id)
{
- return $this->dao->select('*')->from(TABLE_INTEGRATION)->where('id')->eq($id)->fetch();
+ return $this->dao->select('*')->from(TABLE_JOB)->where('id')->eq($id)->fetch();
}
/**
- * Get integration list.
+ * Get job list.
*
* @param string $orderBy
* @param object $pager
@@ -33,7 +33,7 @@ class integrationModel extends model
*/
public function getList($orderBy = 'id_desc', $pager = null)
{
- return $this->dao->select('t1.*, t2.name as repoName, t3.name as jenkinsName')->from(TABLE_INTEGRATION)->alias('t1')
+ return $this->dao->select('t1.*, t2.name as repoName, t3.name as jenkinsName')->from(TABLE_JOB)->alias('t1')
->leftJoin(TABLE_REPO)->alias('t2')->on('t1.repo=t2.id')
->leftJoin(TABLE_JENKINS)->alias('t3')->on('t1.jkHost=t3.id')
->where('t1.deleted')->eq('0')
@@ -51,54 +51,76 @@ class integrationModel extends model
*/
public function getListByTriggerType($triggerType, $repoIdList = array())
{
- return $this->dao->select('*')->from(TABLE_INTEGRATION)
+ return $this->dao->select('*')->from(TABLE_JOB)
->where('deleted')->eq('0')
->andWhere('triggerType')->eq($triggerType)
->beginIF($repoIdList)->andWhere('repo')->in($repoIdList)->fi()
->fetchAll('id');
}
+ public function getTriggerConfig($job)
+ {
+ $triggerType = zget($this->lang->job->triggerTypeList, $job->triggerType);
+ if($job->triggerType == 'tag')
+ {
+ if(empty($job->svnDir)) return $triggerType;
+
+ $triggerType = $this->lang->job->dirChange;
+ return "{$triggerType}({$job->svnDir})";
+ }
+
+ if($job->triggerType == 'commit') return "{$triggerType}({$job->comment})";
+
+ if($job->triggerType == 'schedule')
+ {
+ $atDay = '';
+ foreach(explode(',', $job->atDay) as $day) $atDay .= zget($this->lang->datepicker->dayNames, trim($day), '') . ',';
+ $atDay = trim($atDay, ',');
+ return "{$triggerType}({$atDay}, {$job->atTime})";
+ }
+ }
+
/**
- * Create integration
+ * Create job
*
* @access public
* @return void
*/
public function create()
{
- $integration = fixer::input('post')
+ $job = fixer::input('post')
->setDefault('atDay', '')
->setIF($this->post->repoType != 'Subversion', 'svnDir', '')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->remove('repoType')
->get();
- if($integration->triggerType == 'schedule') $integration->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
- if($integration->triggerType == 'tag' and $this->post->repoType == 'Subversion')
+ if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
+ if($job->triggerType == 'tag' and $this->post->repoType == 'Subversion')
{
- $integration->svnDir = array_pop($_POST['svnDir']);
- if($integration->svnDir == '/' and $_POST['svnDir']) $integration->svnDir = array_pop($_POST['svnDir']);
+ $job->svnDir = array_pop($_POST['svnDir']);
+ if($job->svnDir == '/' and $_POST['svnDir']) $job->svnDir = array_pop($_POST['svnDir']);
}
- $this->dao->insert(TABLE_INTEGRATION)->data($integration)
- ->batchCheck($this->config->integration->create->requiredFields, 'notempty')
+ $this->dao->insert(TABLE_JOB)->data($job)
+ ->batchCheck($this->config->job->create->requiredFields, 'notempty')
- ->batchCheckIF($integration->triggerType === 'schedule', "atDay,atTime", 'notempty')
- ->batchCheckIF($integration->triggerType === 'commit', "comment", 'notempty')
+ ->batchCheckIF($job->triggerType === 'schedule', "atDay,atTime", 'notempty')
+ ->batchCheckIF($job->triggerType === 'commit', "comment", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnDir", 'notempty')
->autoCheck()
->exec();
$id = $this->dao->lastInsertId();
- if($integration->triggerType == 'schedule' and strpos($integration->atDay, date('w')) !== false) $this->loadModel('compile')->createByIntegration($id);
- if($integration->triggerType == 'tag')
+ if($job->triggerType == 'schedule' and strpos($job->atDay, date('w')) !== false) $this->loadModel('compile')->createByJob($id);
+ if($job->triggerType == 'tag')
{
- $repo = $this->loadModel('repo')->getRepoByID($integration->repo);
+ $repo = $this->loadModel('repo')->getRepoByID($job->repo);
$lastTag = '';
if($this->post->repoType != 'Subversion')
{
- $dirs = $this->loadModel('svn')->getRepoTags($repo, $integration->svnDir);
+ $dirs = $this->loadModel('svn')->getRepoTags($repo, $job->svnDir);
end($dirs);
$lastTag = current($dirs);
}
@@ -108,13 +130,13 @@ class integrationModel extends model
end($tags);
$lastTag = current($tags);
}
- $this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($id)->exec();
+ $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($id)->exec();
}
return true;
}
/**
- * Update integration
+ * Update job
*
* @param int $id
* @access public
@@ -122,8 +144,8 @@ class integrationModel extends model
*/
public function update($id)
{
- $oldIntegration = $this->getById($id);
- $integration = fixer::input('post')
+ $oldJob = $this->getById($id);
+ $job = fixer::input('post')
->setDefault('atDay', '')
->setIF($this->post->repoType != 'Subversion', 'svnDir', '')
->setIF($this->post->triggerType != 'commit', 'comment', '')
@@ -134,41 +156,41 @@ class integrationModel extends model
->add('editedDate', helper::now())
->remove('repoType')
->get();
- if($integration->triggerType == 'schedule') $integration->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
- if($integration->triggerType == 'tag' and $this->post->repoType == 'Subversion')
+ if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
+ if($job->triggerType == 'tag' and $this->post->repoType == 'Subversion')
{
- $integration->svnDir = array_pop($_POST['svnDir']);
- if($integration->svnDir == '/' and $_POST['svnDir']) $integration->svnDir = array_pop($_POST['svnDir']);
+ $job->svnDir = array_pop($_POST['svnDir']);
+ if($job->svnDir == '/' and $_POST['svnDir']) $job->svnDir = array_pop($_POST['svnDir']);
}
- $this->dao->update(TABLE_INTEGRATION)->data($integration)
- ->batchCheck($this->config->integration->edit->requiredFields, 'notempty')
+ $this->dao->update(TABLE_JOB)->data($job)
+ ->batchCheck($this->config->job->edit->requiredFields, 'notempty')
- ->batchCheckIF($integration->triggerType === 'schedule', "atDay,atTime", 'notempty')
- ->batchCheckIF($integration->triggerType === 'commit', "comment", 'notempty')
+ ->batchCheckIF($job->triggerType === 'schedule', "atDay,atTime", 'notempty')
+ ->batchCheckIF($job->triggerType === 'commit', "comment", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnDir", 'notempty')
->autoCheck()
->where('id')->eq($id)
->exec();
- if($integration->triggerType == 'schedule')
+ if($job->triggerType == 'schedule')
{
$week = date('w');
- if($integration->triggerType != $oldIntegration->triggerType or strpos($oldIntegration->atDay, $week) === false)
+ if($job->triggerType != $oldJob->triggerType or strpos($oldJob->atDay, $week) === false)
{
- if(strpos($integration->atDay, $week) !== false) $this->loadModel('compile')->createByIntegration($integration->id);
+ if(strpos($job->atDay, $week) !== false) $this->loadModel('compile')->createByJob($job->id);
}
}
- elseif($integration->triggerType == 'tag')
+ elseif($job->triggerType == 'tag')
{
- if($integration->triggerType != $oldIntegration->triggerType or $integration->repo != $oldIntegration->repo)
+ if($job->triggerType != $oldJob->triggerType or $job->repo != $oldJob->repo)
{
- $repo = $this->loadModel('repo')->getRepoByID($integration->repo);
+ $repo = $this->loadModel('repo')->getRepoByID($job->repo);
$lastTag = '';
if($this->post->repoType == 'Subversion')
{
- $dirs = $this->loadModel('svn')->getRepoTags($repo, $integration->svnDir);
+ $dirs = $this->loadModel('svn')->getRepoTags($repo, $job->svnDir);
end($dirs);
$lastTag = current($dirs);
}
@@ -178,14 +200,14 @@ class integrationModel extends model
end($tags);
$lastTag = current($tags);
}
- $this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($id)->exec();
+ $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($id)->exec();
}
}
return true;
}
/**
- * Exec integration.
+ * Exec job.
*
* @param int $id
* @access public
@@ -193,32 +215,32 @@ class integrationModel extends model
*/
public function exec($id)
{
- $integration = $this->dao->select('t1.id,t1.name,t1.repo,t1.jkJob,t1.triggerType,t1.atTime,t2.name as jenkinsName,t2.url,t2.account,t2.token,t2.password')
- ->from(TABLE_INTEGRATION)->alias('t1')
+ $job = $this->dao->select('t1.id,t1.name,t1.repo,t1.jkJob,t1.triggerType,t1.atTime,t2.name as jenkinsName,t2.url,t2.account,t2.token,t2.password')
+ ->from(TABLE_JOB)->alias('t1')
->leftJoin(TABLE_JENKINS)->alias('t2')->on('t1.jkHost=t2.id')
->where('t1.id')->eq($id)
->fetch();
- if(!$integration) return false;
+ if(!$job) return false;
- $buildUrl = $this->loadModel('compile')->getBuildUrl($integration);
+ $buildUrl = $this->loadModel('compile')->getBuildUrl($job);
$build = new stdclass();
- $build->integration = $integration->id;
- $build->name = $integration->name;
+ $build->job = $job->id;
+ $build->name = $job->name;
$now = helper::now();
$data = '';
- if($integration->triggerType == 'tag')
+ if($job->triggerType == 'tag')
{
- $repo = $this->loadModel('repo')->getRepoById($integration->repo);
+ $repo = $this->loadModel('repo')->getRepoById($job->repo);
$lastTag = '';
if($repo->SCM == 'Subversion')
{
- $dirs = $this->loadModel('svn')->getRepoTags($repo, $integration->svnDir);
+ $dirs = $this->loadModel('svn')->getRepoTags($repo, $job->svnDir);
if($dirs)
{
end($dirs);
$lastTag = current($dirs);
- $lastTag = rtrim($repo->path , '/') . '/' . trim($integration->svnDir, '/') . '/' . $lastTag;
+ $lastTag = rtrim($repo->path , '/') . '/' . trim($job->svnDir, '/') . '/' . $lastTag;
}
}
else
@@ -234,15 +256,15 @@ class integrationModel extends model
if($lastTag)
{
$build->tag = $lastTag;
- $this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($integration->id)->exec();
+ $this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec();
$data = new stdClass();
$data->PARAM_TAG = $lastTag;
}
}
- elseif($integration->triggerType == 'schedule')
+ elseif($job->triggerType == 'schedule')
{
- $build->atTime = $integration->atTime;
+ $build->atTime = $job->atTime;
}
$build->queue = $this->loadModel('ci')->sendRequest($buildUrl, $data);
@@ -251,8 +273,8 @@ class integrationModel extends model
$build->createdDate = $now;
$build->updateDate = $now;
$this->dao->insert(TABLE_COMPILE)->data($build)->exec();
- $this->dao->update(TABLE_INTEGRATION)->set('lastExec')->eq($now)->set('lastStatus')->eq($build->status)->where('id')->eq($integration->id)->exec();
+ $this->dao->update(TABLE_JOB)->set('lastExec')->eq($now)->set('lastStatus')->eq($build->status)->where('id')->eq($job->id)->exec();
- return !dao::isError();
+ return $build->status;
}
}
diff --git a/module/job/view/browse.html.php b/module/job/view/browse.html.php
new file mode 100644
index 0000000000..b2c0e613e8
--- /dev/null
+++ b/module/job/view/browse.html.php
@@ -0,0 +1,68 @@
+
+ * @package job
+ * @version $Id$
+ * @link http://www.zentao.net
+ */
+?>
+
+
+
+ createLink('job', 'browse'), "{$lang->ci->plan}", '', "class='btn btn-link btn-active-text'");?>
+ createLink('compile', 'browse'), "{$lang->ci->history}", '', "class='btn btn-link'");?>
+
+
+ " . $lang->job->create, '', "class='btn btn-primary'");?>
+
+
+
+
diff --git a/module/integration/view/create.html.php b/module/job/view/create.html.php
similarity index 76%
rename from module/integration/view/create.html.php
rename to module/job/view/create.html.php
index ed7d9830b4..d36b50d71e 100644
--- a/module/integration/view/create.html.php
+++ b/module/job/view/create.html.php
@@ -1,11 +1,11 @@
- * @package integration
+ * @package job
* @version $Id$
* @link http://www.zentao.net
*/
@@ -14,33 +14,33 @@
-integration->dirChange);?>
-integration->buildTag);?>
+job->dirChange);?>
+job->buildTag);?>
-
integration->create; ?>
+ job->create; ?>