* move integration to job.
This commit is contained in:
@@ -170,7 +170,7 @@ define('TABLE_SCORE', '`' . $config->db->prefix . 'score`');
|
||||
define('TABLE_NOTIFY', '`' . $config->db->prefix . 'notify`');
|
||||
define('TABLE_OAUTH', '`' . $config->db->prefix . 'oauth`');
|
||||
define('TABLE_JENKINS', '`' . $config->db->prefix . 'jenkins`');
|
||||
define('TABLE_INTEGRATION', '`' . $config->db->prefix . 'integration`');
|
||||
define('TABLE_JOB', '`' . $config->db->prefix . 'job`');
|
||||
define('TABLE_COMPILE', '`' . $config->db->prefix . 'compile`');
|
||||
|
||||
define('TABLE_REPO', '`' . $config->db->prefix . 'repo`');
|
||||
|
||||
@@ -86,3 +86,5 @@ ALTER TABLE `zt_jenkins` DROP `encrypt`;
|
||||
|
||||
ALTER TABLE `zt_compile` ADD `atTime` varchar(10) COLLATE 'utf8_general_ci' NULL AFTER `logs`;
|
||||
ALTER TABLE `zt_compile` ADD `tag` varchar(255) COLLATE 'utf8_general_ci' NULL AFTER `logs`;
|
||||
ALTER TABLE `zt_integration` RENAME TO `zt_job`;
|
||||
ALTER TABLE `zt_compile` CHANGE `integration` `job` mediumint(8) unsigned NOT NULL AFTER `name`;
|
||||
|
||||
@@ -30,13 +30,13 @@ class ci extends control
|
||||
*/
|
||||
public function initQueue()
|
||||
{
|
||||
$scheduleJobs = $this->loadModel('integration')->getListByTriggerType('schedule');
|
||||
$scheduleJobs = $this->loadModel('job')->getListByTriggerType('schedule');
|
||||
|
||||
$week = date('w');
|
||||
$this->loadModel('compile');
|
||||
foreach($scheduleJobs as $job)
|
||||
{
|
||||
if(strpos($job->atDay, $week) !== false) $this->compile->createByIntegration($job->id, $job->atTime, 'atTime');
|
||||
if(strpos($job->atDay, $week) !== false) $this->compile->createByJob($job->id, $job->atTime, 'atTime');
|
||||
}
|
||||
echo 'success';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$lang->ci->common = 'CI';
|
||||
|
||||
$lang->ci->integration = 'Integration';
|
||||
$lang->ci->plan = 'Plan';
|
||||
$lang->ci->history = 'History';
|
||||
$lang->ci->job = 'Construction';
|
||||
$lang->ci->plan = 'Plan';
|
||||
$lang->ci->history = 'History';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$lang->ci->common = '持续集成';
|
||||
|
||||
$lang->ci->integration = '构建';
|
||||
$lang->ci->plan = '构建计划';
|
||||
$lang->ci->history = '构建历史';
|
||||
$lang->ci->job = '构建';
|
||||
$lang->ci->plan = '构建计划';
|
||||
$lang->ci->history = '构建历史';
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ class ciModel extends model
|
||||
{
|
||||
$compiles = $this->dao->select('t1.*, t2.jkJob, t3.name as jenkinsName,t3.url,t3.account,t3.token,t3.password')
|
||||
->from(TABLE_COMPILE)->alias('t1')
|
||||
->leftJoin(TABLE_INTEGRATION)->alias('t2')->on('t1.integration=t2.id')
|
||||
->leftJoin(TABLE_JOB)->alias('t2')->on('t1.job=t2.id')
|
||||
->leftJoin(TABLE_JENKINS)->alias('t3')->on('t2.jkHost=t3.id')
|
||||
->where('t1.status')->ne('success')
|
||||
->andWhere('t1.status')->ne('fail')
|
||||
@@ -109,7 +109,7 @@ class ciModel extends model
|
||||
public function updateBuildStatus($build, $status)
|
||||
{
|
||||
$this->dao->update(TABLE_COMPILE)->set('status')->eq($status)->where('id')->eq($build->id)->exec();
|
||||
$this->dao->update(TABLE_INTEGRATION)->set('lastExec')->eq(helper::now())->set('lastStatus')->eq($status)->where('id')->eq($build->integration)->exec();
|
||||
$this->dao->update(TABLE_JOB)->set('lastExec')->eq(helper::now())->set('lastStatus')->eq($status)->where('id')->eq($build->job)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -335,19 +335,19 @@ $lang->caselib->menu->caselib = array('link' => 'Case Library|caselib|browse|l
|
||||
$lang->ci = new stdclass();
|
||||
$lang->ci->menu = new stdclass();
|
||||
$lang->ci->menu->code = array('link' => 'Code|repo|browse|repoID=%s', 'alias' => 'diff,view,revision,log,blame,showsynccomment');
|
||||
$lang->ci->menu->build = array('link' => 'Build|integration|browse', 'subModule' => 'compile,integration');
|
||||
$lang->ci->menu->build = array('link' => 'Build|job|browse', 'subModule' => 'compile,job');
|
||||
$lang->ci->menu->jenkins = array('link' => 'Jenkins|jenkins|browse', 'alias' => 'create,edit');
|
||||
$lang->ci->menu->maintain = array('link' => 'Repo|repo|maintain', 'alias' => 'create,edit');
|
||||
$lang->ci->menu->rules = array('link' => 'Rule|repo|setrules');
|
||||
|
||||
$lang->repo = new stdclass();
|
||||
$lang->jenkins = new stdclass();
|
||||
$lang->compile = new stdclass();
|
||||
$lang->integration = new stdclass();
|
||||
$lang->repo->menu = $lang->ci->menu;
|
||||
$lang->jenkins->menu = $lang->ci->menu;
|
||||
$lang->compile->menu = $lang->ci->menu;
|
||||
$lang->integration->menu = $lang->ci->menu;
|
||||
$lang->repo = new stdclass();
|
||||
$lang->jenkins = new stdclass();
|
||||
$lang->compile = new stdclass();
|
||||
$lang->job = new stdclass();
|
||||
$lang->repo->menu = $lang->ci->menu;
|
||||
$lang->jenkins->menu = $lang->ci->menu;
|
||||
$lang->compile->menu = $lang->ci->menu;
|
||||
$lang->job->menu = $lang->ci->menu;
|
||||
|
||||
/* Doc menu settings. */
|
||||
$lang->doc = new stdclass();
|
||||
|
||||
@@ -335,19 +335,19 @@ $lang->caselib->menu->caselib = array('link' => '用例库|caselib|browse|libI
|
||||
$lang->ci = new stdclass();
|
||||
$lang->ci->menu = new stdclass();
|
||||
$lang->ci->menu->code = array('link' => '代码|repo|browse|repoID=%s', 'alias' => 'diff,view,revision,log,blame,showsynccomment');
|
||||
$lang->ci->menu->build = array('link' => '构建|integration|browse', 'subModule' => 'compile,integration');
|
||||
$lang->ci->menu->build = array('link' => '构建|job|browse', 'subModule' => 'compile,job');
|
||||
$lang->ci->menu->jenkins = array('link' => 'Jenkins|jenkins|browse', 'alias' => 'create,edit');
|
||||
$lang->ci->menu->maintain = array('link' => '版本库|repo|maintain', 'alias' => 'create,edit');
|
||||
$lang->ci->menu->rules = array('link' => '指令|repo|setrules');
|
||||
|
||||
$lang->repo = new stdclass();
|
||||
$lang->jenkins = new stdclass();
|
||||
$lang->compile = new stdclass();
|
||||
$lang->integration = new stdclass();
|
||||
$lang->repo->menu = $lang->ci->menu;
|
||||
$lang->jenkins->menu = $lang->ci->menu;
|
||||
$lang->compile->menu = $lang->ci->menu;
|
||||
$lang->integration->menu = $lang->ci->menu;
|
||||
$lang->repo = new stdclass();
|
||||
$lang->jenkins = new stdclass();
|
||||
$lang->compile = new stdclass();
|
||||
$lang->job = new stdclass();
|
||||
$lang->repo->menu = $lang->ci->menu;
|
||||
$lang->jenkins->menu = $lang->ci->menu;
|
||||
$lang->compile->menu = $lang->ci->menu;
|
||||
$lang->job->menu = $lang->ci->menu;
|
||||
|
||||
/* 文档视图菜单设置。*/
|
||||
$lang->doc = new stdclass();
|
||||
@@ -487,10 +487,10 @@ $lang->menugroup->entry = 'admin';
|
||||
$lang->menugroup->webhook = 'admin';
|
||||
$lang->menugroup->message = 'admin';
|
||||
|
||||
$lang->menugroup->repo = 'ci';
|
||||
$lang->menugroup->jenkins = 'ci';
|
||||
$lang->menugroup->compile = 'ci';
|
||||
$lang->menugroup->integration = 'ci';
|
||||
$lang->menugroup->repo = 'ci';
|
||||
$lang->menugroup->jenkins = 'ci';
|
||||
$lang->menugroup->compile = 'ci';
|
||||
$lang->menugroup->job = 'ci';
|
||||
|
||||
/* 错误提示信息。*/
|
||||
$lang->error = new stdclass();
|
||||
|
||||
+10
-10
@@ -28,7 +28,7 @@ class compile extends control
|
||||
/**
|
||||
* Browse jenkins build.
|
||||
*
|
||||
* @param int $integrationID
|
||||
* @param int $jobID
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
@@ -36,18 +36,18 @@ class compile extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browse($integrationID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
public function browse($jobID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$this->view->title = $this->lang->ci->integration . $this->lang->colon . $this->lang->compile->browse;
|
||||
$this->view->position[] = html::a($this->createLink('integration', 'browse'), $this->lang->ci->integration);
|
||||
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->compile->browse;
|
||||
$this->view->position[] = html::a($this->createLink('job', 'browse'), $this->lang->ci->job);
|
||||
$this->view->position[] = $this->lang->compile->browse;
|
||||
|
||||
$this->app->loadLang('integration');
|
||||
$this->view->integrationID = $integrationID;
|
||||
$this->view->buildList = $this->compile->getList($integrationID, $orderBy, $pager);
|
||||
$this->app->loadLang('job');
|
||||
$this->view->jobID = $jobID;
|
||||
$this->view->buildList = $this->compile->getList($jobID, $orderBy, $pager);
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->pager = $pager;
|
||||
$this->display();
|
||||
@@ -66,9 +66,9 @@ class compile extends control
|
||||
$this->view->logs = str_replace("\r\n","<br />", $build->logs);
|
||||
$this->view->build = $build;
|
||||
|
||||
$this->view->title = $this->lang->ci->integration . $this->lang->colon . $this->lang->compile->logs;
|
||||
$this->view->position[] = html::a($this->createLink('integration', 'browse'), $this->lang->ci->integration);
|
||||
$this->view->position[] = html::a($this->createLink('compile', 'browse', "integrationID=" . $build->integration), $this->lang->compile->browse);
|
||||
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->compile->logs;
|
||||
$this->view->position[] = html::a($this->createLink('job', 'browse'), $this->lang->ci->job);
|
||||
$this->view->position[] = html::a($this->createLink('compile', 'browse', "jobID=" . $build->job), $this->lang->compile->browse);
|
||||
$this->view->position[] = $this->lang->compile->logs;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
+17
-17
@@ -26,21 +26,21 @@ class compileModel extends model
|
||||
/**
|
||||
* Get build list.
|
||||
*
|
||||
* @param int $integrationID
|
||||
* @param int $jobID
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($integrationID, $orderBy = 'id_desc', $pager = null)
|
||||
public function getList($jobID, $orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
return $this->dao->select('t1.id, t1.name, t1.status, t1.createdDate, t2.jkJob,t2.triggerType,t2.comment,t2.atDay,t2.atTime, t3.name as repoName, t4.name as jenkinsName')->from(TABLE_COMPILE)->alias('t1')
|
||||
->leftJoin(TABLE_INTEGRATION)->alias('t2')->on('t1.integration=t2.id')
|
||||
->leftJoin(TABLE_JOB)->alias('t2')->on('t1.job=t2.id')
|
||||
->leftJoin(TABLE_REPO)->alias('t3')->on('t2.repo=t3.id')
|
||||
->leftJoin(TABLE_JENKINS)->alias('t4')->on('t2.jkHost=t4.id')
|
||||
->where('t1.deleted')->eq('0')
|
||||
->andWhere('t1.integration')->ne('0')
|
||||
->beginIF(!empty($integrationID))->andWhere('t1.integration')->eq($integrationID)->fi()
|
||||
->andWhere('t1.job')->ne('0')
|
||||
->beginIF(!empty($jobID))->andWhere('t1.job')->eq($jobID)->fi()
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
@@ -77,21 +77,21 @@ class compileModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Save build by integration
|
||||
* Save build by job
|
||||
*
|
||||
* @param int $integrationID
|
||||
* @param int $jobID
|
||||
* @param string $data
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function createByIntegration($integrationID, $data = '', $type = 'tag')
|
||||
public function createByJob($jobID, $data = '', $type = 'tag')
|
||||
{
|
||||
$integration = $this->dao->select('id,name')->from(TABLE_INTEGRATION)->where('id')->eq($integrationID)->fetch();
|
||||
$job = $this->dao->select('id,name')->from(TABLE_JOB)->where('id')->eq($jobID)->fetch();
|
||||
|
||||
$build = new stdClass();
|
||||
$build->integration = $integration->id;
|
||||
$build->name = $integration->name;
|
||||
$build->job = $job->id;
|
||||
$build->name = $job->name;
|
||||
$build->$type = $data;
|
||||
$build->createdBy = $this->app->user->account;
|
||||
$build->createdDate = helper::now();
|
||||
@@ -108,13 +108,13 @@ class compileModel extends model
|
||||
*/
|
||||
public function execByCompile($compile)
|
||||
{
|
||||
$integration = $this->dao->select('t1.id,t1.name,t1.repo,t1.jkJob,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,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($compile->integration)
|
||||
->where('t1.id')->eq($compile->job)
|
||||
->fetch();
|
||||
|
||||
if(!$integration) return false;
|
||||
if(!$job) return false;
|
||||
|
||||
$tagData = '';
|
||||
if($compile->tag)
|
||||
@@ -123,13 +123,13 @@ class compileModel extends model
|
||||
$tagData->PARAM_TAG = $compile->tag;
|
||||
}
|
||||
|
||||
$buildUrl = $this->getBuildUrl($integration);
|
||||
$buildUrl = $this->getBuildUrl($job);
|
||||
$build = new stdclass();
|
||||
$build->queue = $this->loadModel('ci')->sendRequest($buildUrl, $tagData);
|
||||
$build->status = $build->queue ? 'created' : 'create_fail';
|
||||
$build->updateDate = helper::now();
|
||||
$this->dao->update(TABLE_COMPILE)->data($build)->where('id')->eq($compile->id)->exec();
|
||||
$this->dao->update(TABLE_INTEGRATION)->set('lastStatus')->eq($build->status)->set('lastExec')->eq($build->updateDate)->where('id')->eq($compile->integration)->exec();
|
||||
$this->dao->update(TABLE_JOB)->set('lastStatus')->eq($build->status)->set('lastExec')->eq($build->updateDate)->where('id')->eq($compile->job)->exec();
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-left">
|
||||
<?php
|
||||
echo html::a($this->createLink('integration', 'browse'), "<span class='text'>{$lang->ci->plan}</span>", '', "class='btn btn-link'");
|
||||
echo html::a($this->createLink('job', 'browse'), "<span class='text'>{$lang->ci->plan}</span>", '', "class='btn btn-link'");
|
||||
echo html::a($this->createLink('compile', 'browse'), "<span class='text'>{$lang->ci->history}</span>", '', "class='btn btn-link btn-active-text'");
|
||||
?>
|
||||
</div>
|
||||
@@ -25,49 +25,30 @@
|
||||
<table id='buildList' class='table has-sort-head table-fixed'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
<?php $vars = "integrationID={$integrationID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<?php $vars = "jobID={$jobID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<th class='w-60px'><?php common::printOrderLink('id', $orderBy, $vars, $lang->compile->id);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->compile->name);?></th>
|
||||
<th class='text-left'><?php echo $lang->integration->repo;?></th>
|
||||
<th class='w-250px text-left'><?php echo $lang->integration->jenkins;?></th>
|
||||
<th class='w-200px text-left'><?php echo $lang->integration->triggerType;?></th>
|
||||
<th class='w-80px text-left'><?php common::printOrderLink('status', $orderBy, $vars, $lang->compile->status);?></th>
|
||||
<th class='w-130px'><?php common::printOrderLink('createdDate', $orderBy, $vars, $lang->compile->time);?></th>
|
||||
<th class='w-150px text-left'><?php echo $lang->job->repo;?></th>
|
||||
<th class='w-250px text-left'><?php echo $lang->job->jenkins;?></th>
|
||||
<th class='text-left'><?php echo $lang->job->triggerType;?></th>
|
||||
<th class='w-80px text-center'><?php common::printOrderLink('status', $orderBy, $vars, $lang->compile->status);?></th>
|
||||
<th class='w-130px text-center'><?php common::printOrderLink('createdDate', $orderBy, $vars, $lang->compile->time);?></th>
|
||||
<th class='c-actions-1'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class='text-left'>
|
||||
<?php foreach($buildList as $id => $build):?>
|
||||
<tr>
|
||||
<td class='text-center'><?php echo $id;?></td>
|
||||
<td class='text' title='<?php echo $build->name;?>'><?php echo $build->name;?></td>
|
||||
<td class='text' title='<?php echo $build->repoName;?>'><?php echo $build->repoName;?></td>
|
||||
<td class='text' title='<?php echo $build->jenkinsName;?>'><?php echo urldecode($build->jkJob) . "@{$build->jenkinsName}";?></td>
|
||||
<?php
|
||||
$triggerType = zget($lang->integration->triggerTypeList, $build->triggerType);
|
||||
$triggerConfig = '';
|
||||
if($build->triggerType == 'tag' and !empty($build->svnDir))
|
||||
{
|
||||
$triggerType = $lang->integration->dirChange;
|
||||
$triggerConfig = "({$build->svnDir})";
|
||||
}
|
||||
elseif($build->triggerType == 'commit')
|
||||
{
|
||||
$triggerConfig = "({$build->comment})";
|
||||
}
|
||||
elseif($build->triggerType == 'schedule')
|
||||
{
|
||||
$atDay = '';
|
||||
foreach(explode(',', $build->atDay) as $day) $atDay .= zget($lang->datepicker->dayNames, trim($day), '') . ',';
|
||||
$atDay = trim($atDay, ',');
|
||||
|
||||
$triggerConfig = "({$atDay}, {$build->atTime})";
|
||||
}
|
||||
?>
|
||||
<td class='text' title='<?php echo $triggerType . $triggerConfig;?>'><?php echo $triggerType . $triggerConfig;?></td>
|
||||
<td title='<?php echo $build->name;?>'><?php echo $build->name;?></td>
|
||||
<td title='<?php echo $build->repoName;?>'><?php echo $build->repoName;?></td>
|
||||
<?php $jenkins = urldecode($build->jkJob) . '@' . $build->jenkinsName;?>
|
||||
<td title='<?php echo $jenkins; ?>'><?php echo $jenkins; ?></td>
|
||||
<?php $triggerConfig = $this->loadModel('job')->getTriggerConfig($build);?>
|
||||
<td title='<?php echo $triggerConfig;?>'><?php echo $triggerConfig;?></td>
|
||||
<?php $buildStatus = zget($lang->compile->statusList, $build->status);?>
|
||||
<td class='text' title='<?php echo $buildStatus;?>'><?php echo $buildStatus;?></td>
|
||||
<td class='text' title='<?php echo $build->createdDate;?>'><?php echo $build->createdDate;?></td>
|
||||
<td class='text-center' title='<?php echo $buildStatus;?>'><?php echo $buildStatus;?></td>
|
||||
<td title='<?php echo $build->createdDate;?>'><?php echo $build->createdDate;?></td>
|
||||
<td class='c-actions text-center'>
|
||||
<?php common::printIcon('compile', 'logs', "buildID=$id", '', 'list', 'file-text', '', '', '', '', $lang->compile->logs);?>
|
||||
</td>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php echo html::a(helper::createLink('compile', "browse", "integrationID=$build->integration"), "<i class='icon icon-back icon-sm'></i> ". $lang->goback, '', "class='btn btn-secondary'");?>
|
||||
<?php echo html::a(helper::createLink('compile', "browse", "jobID=$build->job"), "<i class='icon icon-back icon-sm'></i> ". $lang->goback, '', "class='btn btn-secondary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
|
||||
+15
-15
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
$config->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';
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
$lang->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';
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
$lang->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'] = '定时计划';
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of integration module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chenqi <chenqi@cnezsoft.com>
|
||||
* @package ci
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-left">
|
||||
<?php echo html::a($this->createLink('integration', 'browse'), "<span class='text'>{$lang->ci->plan}</span>", '', "class='btn btn-link btn-active-text'");?>
|
||||
<?php echo html::a($this->createLink('compile', 'browse'), "<span class='text'>{$lang->ci->history}</span>", '', "class='btn btn-link'");?>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('integration', 'create')) common::printLink('integration', 'create', "", "<i class='icon icon-plus'></i> " . $lang->integration->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='jobList' class='table has-sort-head table-fixed'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<th class='w-60px'><?php common::printOrderLink('id', $orderBy, $vars, $lang->integration->id);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->integration->name);?></th>
|
||||
<th class='w-200px text-left'><?php common::printOrderLink('repo', $orderBy, $vars, $lang->integration->repo);?></th>
|
||||
<th class='w-200px text-left'><?php echo $lang->integration->triggerType;?></th>
|
||||
<th class='w-300px text-left'><?php common::printOrderLink('jkHost', $orderBy, $vars, $lang->integration->jenkins);?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('lastStatus', $orderBy, $vars, $lang->integration->lastStatus);?></th>
|
||||
<th class='w-120px text-left'><?php common::printOrderLink('lastExec', $orderBy, $vars, $lang->integration->lastExec);?></th>
|
||||
<th class='w-120px c-actions-3'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($jobList as $id => $job):?>
|
||||
<tr>
|
||||
<td class='text-center'><?php echo $id; ?></td>
|
||||
<td class='text' title='<?php echo $job->name; ?>'><?php echo $job->name; ?></td>
|
||||
<td class='text' title='<?php echo $job->repoName; ?>'><?php echo $job->repoName; ?></td>
|
||||
<?php
|
||||
$triggerType = zget($lang->integration->triggerTypeList, $job->triggerType);
|
||||
$triggerConfig = '';
|
||||
if($job->triggerType == 'tag' and !empty($job->svnDir))
|
||||
{
|
||||
$triggerType = $lang->integration->dirChange;
|
||||
$triggerConfig = "({$job->svnDir})";
|
||||
}
|
||||
elseif($job->triggerType == 'commit')
|
||||
{
|
||||
$triggerConfig = "({$job->comment})";
|
||||
}
|
||||
elseif($job->triggerType == 'schedule')
|
||||
{
|
||||
$atDay = '';
|
||||
foreach(explode(',', $job->atDay) as $day) $atDay .= zget($lang->datepicker->dayNames, trim($day), '') . ',';
|
||||
$atDay = trim($atDay, ',');
|
||||
|
||||
$triggerConfig = "({$atDay}, {$job->atTime})";
|
||||
}
|
||||
?>
|
||||
<td class='text' title='<?php echo $triggerType . $triggerConfig;?>'><?php echo $triggerType . $triggerConfig;?></td>
|
||||
<td class='text' title='<?php echo $job->jenkinsName; ?>'><?php echo urldecode($job->jkJob) . '@' . $job->jenkinsName; ?></td>
|
||||
<td class='text'><?php if($job->lastStatus) echo zget($lang->compile->statusList, $job->lastStatus);?></td>
|
||||
<td class='text'><?php if($job->lastStatus) echo $job->lastExec;?></td>
|
||||
<td class='c-actions text-center'>
|
||||
<?php
|
||||
common::printIcon('compile', 'browse', "integrationID=$id", '', 'list', 'file-text');
|
||||
common::printIcon('integration', 'edit', "integrationID=$id", '', 'list', 'edit');
|
||||
common::printIcon('integration', 'exec', "integrationID=$id", '', 'list', 'play', 'hiddenwin');
|
||||
if(common::hasPriv('integration', 'delete')) echo html::a($this->createLink('integration', 'delete', "integrationID=$id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->integration->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($jobList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php'; ?>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$config->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';
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of integration of ZenTaoPMS.
|
||||
* The control file of job of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @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'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$lang->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';
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$lang->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'] = '定时计划';
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of integration module of ZenTaoCMS.
|
||||
* The model file of job module of ZenTaoCMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of job module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chenqi <chenqi@cnezsoft.com>
|
||||
* @package job
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-left">
|
||||
<?php echo html::a($this->createLink('job', 'browse'), "<span class='text'>{$lang->ci->plan}</span>", '', "class='btn btn-link btn-active-text'");?>
|
||||
<?php echo html::a($this->createLink('compile', 'browse'), "<span class='text'>{$lang->ci->history}</span>", '', "class='btn btn-link'");?>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('job', 'create')) common::printLink('job', 'create', "", "<i class='icon icon-plus'></i> " . $lang->job->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='jobList' class='table has-sort-head table-fixed'>
|
||||
<thead>
|
||||
<tr class='text-center'>
|
||||
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<th class='w-60px'><?php common::printOrderLink('id', $orderBy, $vars, $lang->job->id);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->job->name);?></th>
|
||||
<th class='w-150px text-left'><?php common::printOrderLink('repo', $orderBy, $vars, $lang->job->repo);?></th>
|
||||
<th class='w-250px text-left'><?php common::printOrderLink('jkHost', $orderBy, $vars, $lang->job->jenkins);?></th>
|
||||
<th class='text-left'><?php echo $lang->job->triggerType;?></th>
|
||||
<th class='w-100px text-center'><?php common::printOrderLink('lastStatus', $orderBy, $vars, $lang->job->lastStatus);?></th>
|
||||
<th class='w-130px text-left'><?php common::printOrderLink('lastExec', $orderBy, $vars, $lang->job->lastExec);?></th>
|
||||
<th class='w-120px c-actions-3'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class='text-left'>
|
||||
<?php foreach($jobList as $id => $job):?>
|
||||
<tr>
|
||||
<td class='text-center'><?php echo $id; ?></td>
|
||||
<td title='<?php echo $job->name; ?>'><?php echo $job->name; ?></td>
|
||||
<td title='<?php echo $job->repoName; ?>'><?php echo $job->repoName; ?></td>
|
||||
<?php $jenkins = urldecode($job->jkJob) . '@' . $job->jenkinsName;?>
|
||||
<td title='<?php echo $jenkins; ?>'><?php echo $jenkins; ?></td>
|
||||
<?php $triggerConfig = $this->job->getTriggerConfig($job);?>
|
||||
<td title='<?php echo $triggerConfig;?>'><?php echo $triggerConfig;?></td>
|
||||
<td class='text-center'><?php if($job->lastStatus) echo zget($lang->compile->statusList, $job->lastStatus);?></td>
|
||||
<td><?php if($job->lastStatus) echo $job->lastExec;?></td>
|
||||
<td class='c-actions text-center'>
|
||||
<?php
|
||||
common::printIcon('compile', 'browse', "jobID=$id", '', 'list', 'file-text');
|
||||
common::printIcon('job', 'edit', "jobID=$id", '', 'list', 'edit');
|
||||
common::printIcon('job', 'exec', "jobID=$id", '', 'list', 'play', 'hiddenwin');
|
||||
if(common::hasPriv('job', 'delete')) echo html::a($this->createLink('job', 'delete', "jobID=$id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->job->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($jobList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php'; ?>
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* The create view file of integration module of ZenTaoPMS.
|
||||
* The create view file of job module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chenqi <chenqi@cnezsoft.com>
|
||||
* @package integration
|
||||
* @package job
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
@@ -14,33 +14,33 @@
|
||||
|
||||
<?php js::set('repoTypes', $repoTypes);?>
|
||||
<?php js::set('triggerType', 'tag');?>
|
||||
<?php js::set('dirChange', $lang->integration->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->integration->buildTag);?>
|
||||
<?php js::set('dirChange', $lang->job->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->job->buildTag);?>
|
||||
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->integration->create; ?></h2>
|
||||
<h2><?php echo $lang->job->create; ?></h2>
|
||||
</div>
|
||||
<form id='jobForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->integration->name; ?></th>
|
||||
<th class='w-120px'><?php echo $lang->job->name; ?></th>
|
||||
<td class='required'><?php echo html::input('name', '', "class='form-control'"); ?></td>
|
||||
<td colspan="2" ></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->repo; ?></th>
|
||||
<th><?php echo $lang->job->repo; ?></th>
|
||||
<td><?php echo html::select('repo', $repoPairs, '', "class='form-control chosen'"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->triggerType; ?></th>
|
||||
<td><?php echo html::select('triggerType', $lang->integration->triggerTypeList, '', "class='form-control chosen'");?></td>
|
||||
<th><?php echo $lang->job->triggerType; ?></th>
|
||||
<td><?php echo html::select('triggerType', $lang->job->triggerTypeList, '', "class='form-control chosen'");?></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr id='svnDirBox' class='svn-fields'>
|
||||
<th><?php echo $lang->integration->svnDir;?></th>
|
||||
<th><?php echo $lang->job->svnDir;?></th>
|
||||
<td colspan='2'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('svnDir[]', array('' => ''), '', "class='form-control chosen'");?>
|
||||
@@ -48,9 +48,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="comment-fields">
|
||||
<th><?php echo $lang->integration->comment;?></th>
|
||||
<th><?php echo $lang->job->comment;?></th>
|
||||
<td class='required'><?php echo html::input('comment', '', "class='form-control'");?></td>
|
||||
<td colspan='2'><?php echo $lang->integration->commitEx;?></td>
|
||||
<td colspan='2'><?php echo $lang->job->commitEx;?></td>
|
||||
</tr>
|
||||
<tr class="custom-fields">
|
||||
<th rowspan='2'></th>
|
||||
@@ -59,19 +59,19 @@
|
||||
<tr class="custom-fields">
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon'><?php echo $lang->integration->atTime;?></span>
|
||||
<span class='input-group-addon'><?php echo $lang->job->atTime;?></span>
|
||||
<?php echo html::input('atTime', '', "class='form-control form-time'");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->jkHost; ?></th>
|
||||
<th><?php echo $lang->job->jkHost; ?></th>
|
||||
<td colspan='2'>
|
||||
<div class='table-row'>
|
||||
<div class='table-col'><?php echo html::select('jkHost', $jkHostList, '', "class='form-control chosen'"); ?></div>
|
||||
<div id='jkJobBox' class='table-col'>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon'><?php echo $lang->integration->jkJob; ?></span>
|
||||
<span class='input-group-addon'><?php echo $lang->job->jkJob; ?></span>
|
||||
<?php echo html::select('jkJob', array('' => ''), '', "class='form-control chosen'"); ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* The edit view file of integration module of ZenTaoPMS.
|
||||
* The edit view file of job module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chenqi <chenqi@cnezsoft.com>
|
||||
* @package integration
|
||||
* @package job
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
@@ -15,35 +15,35 @@
|
||||
<?php js::set('repoTypes', $repoTypes)?>
|
||||
<?php js::set('triggerType', $job->triggerType);?>
|
||||
<?php js::set('jkJob', $job->jkJob);?>
|
||||
<?php js::set('dirChange', $lang->integration->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->integration->buildTag);?>
|
||||
<?php js::set('dirChange', $lang->job->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->job->buildTag);?>
|
||||
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->integration->edit; ?></h2>
|
||||
<h2><?php echo $lang->job->edit; ?></h2>
|
||||
</div>
|
||||
<form id='jobForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->integration->name; ?></th>
|
||||
<th class='w-120px'><?php echo $lang->job->name; ?></th>
|
||||
<td class='required'><?php echo html::input('name', $job->name, "class='form-control'"); ?></td>
|
||||
<td colspan="2" ></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->repo; ?></th>
|
||||
<th><?php echo $lang->job->repo; ?></th>
|
||||
<td><?php echo html::select('repo', $repoPairs, $job->repo, "class='form-control chosen'");?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->triggerType; ?></th>
|
||||
<?php if($repoType == 'Subversion') $lang->integration->triggerTypeList['tag'] = $lang->integration->dirChange;?>
|
||||
<td><?php echo html::select('triggerType', $lang->integration->triggerTypeList, $job->triggerType, "class='form-control chosen'");?></td>
|
||||
<th><?php echo $lang->job->triggerType; ?></th>
|
||||
<?php if($repoType == 'Subversion') $lang->job->triggerTypeList['tag'] = $lang->job->dirChange;?>
|
||||
<td><?php echo html::select('triggerType', $lang->job->triggerTypeList, $job->triggerType, "class='form-control chosen'");?></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr id='svnDirBox' class='svn-fields'>
|
||||
<th><?php echo $lang->integration->svnDir;?></th>
|
||||
<th><?php echo $lang->job->svnDir;?></th>
|
||||
<td colspan='2'>
|
||||
<div class='input-group'>
|
||||
<?php
|
||||
@@ -71,9 +71,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="comment-fields">
|
||||
<th><?php echo $lang->integration->comment;?></th>
|
||||
<th><?php echo $lang->job->comment;?></th>
|
||||
<td class='required'><?php echo html::input('comment', $job->comment, "class='form-control'");?></td>
|
||||
<td colspan='2'><?php echo $lang->integration->commitEx;?></td>
|
||||
<td colspan='2'><?php echo $lang->job->commitEx;?></td>
|
||||
</tr>
|
||||
<tr class="custom-fields">
|
||||
<th rowspan='2'></th>
|
||||
@@ -82,19 +82,19 @@
|
||||
<tr class="custom-fields">
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon'><?php echo $lang->integration->atTime;?></span>
|
||||
<span class='input-group-addon'><?php echo $lang->job->atTime;?></span>
|
||||
<?php echo html::input('atTime', $job->atTime, "class='form-control form-time'");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->integration->jkHost; ?></th>
|
||||
<th><?php echo $lang->job->jkHost; ?></th>
|
||||
<td colspan='2'>
|
||||
<div class='table-row'>
|
||||
<div class='table-col'><?php echo html::select('jkHost', $jkHostList, $job->jkHost, "class='form-control chosen'");?></div>
|
||||
<div id='jkJobBox' class='table-col'>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon'><?php echo $lang->integration->jkJob; ?></span>
|
||||
<span class='input-group-addon'><?php echo $lang->job->jkJob; ?></span>
|
||||
<?php echo html::select('jkJob', array('' => ''), $job->jkJob, "class='form-control chosen'");?>
|
||||
</div>
|
||||
</div>
|
||||
+17
-17
@@ -70,15 +70,15 @@ class svnModel 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;
|
||||
|
||||
$_COOKIE['repoBranch'] = '';
|
||||
foreach($this->repos as $repoID => $repo)
|
||||
@@ -118,12 +118,12 @@ class svnModel 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,17 +136,17 @@ class svnModel extends model
|
||||
}
|
||||
|
||||
/* Create compile by tag. */
|
||||
$integrations = zget($tagGroup, $repoID, array());
|
||||
foreach($integrations as $integration)
|
||||
$jobs = zget($tagGroup, $repoID, array());
|
||||
foreach($jobs as $job)
|
||||
{
|
||||
$dirs = $this->getRepoTags($repo, $integration->svnDir);
|
||||
$dirs = $this->getRepoTags($repo, $job->svnDir);
|
||||
end($dirs);
|
||||
$lastTag = current($dirs);
|
||||
if($lastTag != $integration->lastTag)
|
||||
if($lastTag != $job->lastTag)
|
||||
{
|
||||
$tag = rtrim($repo->path , '/') . '/' . trim($integration->svnDir, '/') . '/' . $lastTag;
|
||||
$this->compile->createByIntegration($integration->id, $tag, 'tag');
|
||||
$this->dao->update(TABLE_INTEGRATION)->set('lastTag')->eq($lastTag)->where('id')->eq($integration->id)->exec();
|
||||
$tag = rtrim($repo->path , '/') . '/' . trim($job->svnDir, '/') . '/' . $lastTag;
|
||||
$this->compile->createByJob($job->id, $tag, 'tag');
|
||||
$this->dao->update(TABLE_JOB)->set('lastTag')->eq($lastTag)->where('id')->eq($job->id)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user