* finish task #6891.

This commit is contained in:
wangyidong
2020-02-20 15:09:25 +08:00
parent 310c31b8ec
commit 928147ac91
30 changed files with 887 additions and 873 deletions
-6
View File
@@ -1,6 +0,0 @@
<?php
$config->job = new stdclass();
$config->job->create = new stdclass();
$config->job->create->requiredFields = 'name,repo,jenkins,jenkinsJob,triggerType';
$config->job->edit = new stdclass();
$config->job->edit->requiredFields = 'name,repo,jenkins,jenkinsJob,triggerType';
+1 -202
View File
@@ -19,16 +19,7 @@ class ci extends control
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
$repoID = $this->session->repoID;
foreach($this->lang->repo->menu as $key => $menu)
{
common::setMenuVars($this->lang->ci->menu, $key, $repoID);
}
// if(common::hasPriv('ci', 'createJob') and strpos(',browsejob,', $this->methodName) > -1) {
// $this->lang->modulePageActions = html::a(helper::createLink('ci', 'createJob'), "<i class='icon icon-plus'></i> " . $this->lang->ci->create, '', "class='btn btn-primary'");
// }
$this->ci->setMenu();
}
/**
@@ -44,197 +35,6 @@ class ci extends control
$this->display();
}
/**
* Browse ci job.
*
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function browseJob($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->view->jobList = $this->ci->listJob($orderBy, $pager);
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->ci->browse;
$this->view->position[] = $this->lang->ci->job;
$this->view->position[] = $this->lang->ci->browse;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->view->method = 'browseJob';
$this->display();
}
/**
* Create a ci job.
*
* @access public
* @return void
*/
public function createJob()
{
if($_POST)
{
$this->ci->createJob();
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browseJob')));
}
$this->app->loadLang('action');
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->ci->create;
$this->view->position[] = html::a(inlink('browseJob'), $this->lang->ci->job);
$this->view->position[] = $this->lang->ci->create;
$repoList = $this->loadModel('repo')->getAllRepos();
$repoPairs = array(0 => '');
$repoTypes = array();
foreach($repoList as $repo)
{
$repoPairs[$repo->id] = $repo->name;
$repoTypes[$repo->id] = $repo->SCM;
}
$this->view->repoPairs = $repoPairs;
$this->view->repoTypes = $repoTypes;
$this->view->jenkinsList = $this->loadModel('jenkins')->listForSelection("true");
$this->display();
}
/**
* Edit a ci job.
*
* @param int $id
* @access public
* @return void
*/
public function editJob($id)
{
$job = $this->ci->getJobByID($id);
if($_POST)
{
$this->ci->updateJob($id);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browseJob')));
}
$this->app->loadLang('action');
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->ci->edit;
$this->view->position[] = html::a(inlink('browseJob'), $this->lang->ci->job);
$this->view->position[] = $this->lang->ci->edit;
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
$repoList = $this->loadModel('repo')->getAllRepos();
$repoPairs = array(0 => '', $repo->id => $repo->name);
$repoTypes[$repo->id] = $repo->SCM;
foreach($repoList as $repo)
{
$repoPairs[$repo->id] = $repo->name;
$repoTypes[$repo->id] = $repo->SCM;
}
$this->view->repoPairs = $repoPairs;
$this->view->repoTypes = $repoTypes;
$this->view->job = $job;
$this->view->jenkinsList = $this->loadModel('jenkins')->listForSelection("true");
$this->display();
}
/**
* Delete a ci job.
*
* @param int $id
* @access public
* @return void
*/
public function deleteJob($id)
{
$this->ci->delete(TABLE_INTEGRATION, $id);
$command = 'moduleName=ci&methodName=exe&parm=' . $id;
$this->dao->delete()->from(TABLE_CRON)->where('command')->eq($command)->exec();
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->send(array('result' => 'success'));
}
/**
* Exec a ci job.
*
* @param int $id
* @access public
* @return void
*/
public function exeJob($id)
{
$result = $this->ci->exeJob($id);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(!$result) $this->send(array('result' => 'fail', 'message' => 'not found'));
$this->send(array('result' => 'success'));
}
/**
* Browse jenkins build.
*
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function browseBuild($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->buildList = $this->ci->listBuild($jobID, $orderBy, $pager);
$this->view->job = $this->ci->getJobByID($jobID);
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->browseBuild;
$this->view->position[] = html::a(inlink('browseJob'), $this->lang->ci->job);
$this->view->position[] = $this->lang->job->browseBuild;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->view->method = 'browseBuild';
$this->display();
}
/**
* View jenkins build logs.
*
* @param int $buildID
* @access public
* @return void
*/
public function viewBuildLogs($buildID)
{
$build = $this->ci->getBuildByID($buildID);
$this->view->logs = str_replace("\r\n","<br />", $build->logs);
$this->view->build = $build;
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->viewLogs;
$this->view->position[] = html::a(inlink('browseJob'), $this->lang->ci->job);
$this->view->position[] = html::a(inlink('browseBuild', "jobID=" . $build->cijob), $this->lang->job->browseBuild);
$this->view->position[] = $this->lang->job->viewLogs;
$this->view->module = 'ci';
$this->display();
}
/**
* Send a request to jenkins to check build status.
*
@@ -248,5 +48,4 @@ class ci extends control
$this->send(array('result' => 'success'));
}
}
+5 -49
View File
@@ -1,50 +1,6 @@
<?php
$lang->ci->common = 'CI';
$lang->ci->at = ' at ';
$lang->ci->jenkins = 'Jenkins';
$lang->ci->repo = 'Repo';
$lang->ci->job = 'Job';
$lang->ci->task = 'Job';
$lang->ci->history = 'Build';
$lang->ci->browse = 'View';
$lang->ci->create = 'Create';
$lang->ci->edit = 'Edit';
$lang->job->browseBuild = 'Build Histories';
$lang->job->viewLogs = 'Build Logs';
$lang->job->exeNow = 'Execute now';
$lang->job->delete = 'Delete';
$lang->job->confirmDelete = 'Do you want to delete this Build?';
$lang->job->buildStatus = 'Build Status';
$lang->job->buildTime = 'Build Time';
$lang->job->id = 'ID';
$lang->job->name = 'Name';
$lang->job->repo = 'Repo';
$lang->job->svnFolder = 'SVN Tag Watch Path';
$lang->job->jenkins = 'Jenkins Server';
$lang->job->jenkinsJob = 'Jenkins Task';
$lang->job->triggerType = 'Trigger';
$lang->job->scheduleType = 'Schedule';
$lang->job->cronExpression = 'Cron Expression';
$lang->job->custom = 'Custom';
$lang->job->at = 'executed on';
$lang->job->exe = '';
$lang->job->scheduleInterval = 'Every';
$lang->job->day = 'days';
$lang->job->lastExe = 'Last Executed';
$lang->job->scheduleTime = 'Time';
$lang->job->example = 'e.g.';
$lang->job->tagEx = 'build_#15, to build Jenkins job that id is 15.';
$lang->job->commitEx = 'start build #15, to build Jenkins job that id is 15.';
$lang->job->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
$lang->job->buildStatusList = array('success' => 'Success', 'fail' => 'Fail', 'created' => 'Created', 'building' => 'Building', 'create_fail' => 'Fail to create', 'timeout' => 'Exec Timeout');
$lang->job->dayTypeList = array('workDay' => 'Weekdays', 'everyDay' => 'Every Day');
$lang->job->triggerTypeList = array('tag' => 'Tag', 'commit' => 'Code Commit', 'schedule' => 'Schedule');
$lang->job->scheduleTypeList = array('cron' => 'Crontab', 'custom' => 'Custom');
$lang->ci->common = 'CI';
$lang->ci->at = ' at ';
$lang->ci->job = 'Job';
$lang->ci->task = 'Job';
$lang->ci->history = 'Build';
+5 -54
View File
@@ -1,55 +1,6 @@
<?php
$lang->ci->common = '持续集成';
$lang->ci->at = '于';
$lang->ci->jenkins = 'Jenkins';
$lang->ci->repo = '版本库';
$lang->ci->job = '构建';
$lang->ci->task = '任务';
$lang->ci->history = '历史';
$lang->ci->browse = '浏览';
$lang->ci->create = '创建';
$lang->ci->edit = '编辑';
$lang->job = new stdclass();
$lang->job->browseBuild = '构建历史';
$lang->job->viewLogs = '构建日志';
$lang->job->create = '创建构建任务';
$lang->job->edit = '编辑构建任务';
$lang->job->exeNow = '立即执行';
$lang->job->delete = '删除构建任务';
$lang->job->confirmDelete = '确认删除该构建任务吗?';
$lang->job->buildStatus = '构建状态';
$lang->job->buildTime = '构建时间';
$lang->job->id = 'ID';
$lang->job->name = '名称';
$lang->job->repo = '代码库';
$lang->job->svnFolder = 'SVN Tag监控路径';
$lang->job->jenkins = 'Jenkins服务';
$lang->job->buildType = '构建类型';
$lang->job->jenkinsJob = 'Jenkins任务名';
$lang->job->triggerType = '触发方式';
$lang->job->scheduleType = '时间计划';
$lang->job->cronExpression = 'Cron表达式';
$lang->job->custom = '自定义';
$lang->job->at = '在';
$lang->job->time = '时间';
$lang->job->exe = '执行';
$lang->job->scheduleInterval = '每隔';
$lang->job->day = '天';
$lang->job->lastExe = '最后执行';
$lang->job->scheduleTime = '时间';
$lang->job->example = '举例';
$lang->job->tagEx = 'build_#15,其中15为Jenkins任务编号';
$lang->job->commitEx = 'start build #15,其中15为Jenkins任务编号';
$lang->job->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
$lang->job->buildStatusList = array('success' => '成功', 'fail' => '失败', 'created' => '新建', 'building' => '构建中', 'create_fail' => '创建失败', 'timeout' => '执行超时');
$lang->job->dayTypeList = array('workDay' => '工作日', 'everyDay' => '每天');
$lang->job->buildTypeList = array('build' => '仅构建', 'buildAndDeploy' => '构建部署', 'buildAndTest' => '构建测试');
$lang->job->triggerTypeList = array('tag' => '打标签', 'commit' => '代码提交注释', 'schedule' => '定时计划');
$lang->job->scheduleTypeList = array('cron' => 'Crontab', 'custom' => '自定义');
$lang->ci->common = '持续集成';
$lang->ci->at = '于';
$lang->ci->job = '构建';
$lang->ci->task = '任务';
$lang->ci->history = '历史';
+35 -279
View File
@@ -1,9 +1,6 @@
<?php
/**
* The model file of ci module 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 Chenqi <chenqi@cnezsoft.com>
* @package product
* @version $Id: $
@@ -12,238 +9,18 @@
class ciModel extends model
{
/**
* Get ci job list.
*
* @param string $orderBy
* @param object $pager
* @param bool $decode
* Set menu.
*
* @access public
* @return array
* @return void
*/
public function listJob($orderBy = 'id_desc', $pager = null, $decode = true)
public function setMenu()
{
$list = $this->dao->
select('t1.*, t2.name repoName, t3.name as jenkinsName')->from(TABLE_INTEGRATION)->alias('t1')
->leftJoin(TABLE_REPO)->alias('t2')->on('t1.repo=t2.id')
->leftJoin(TABLE_JENKINS)->alias('t3')->on('t1.jenkins=t3.id')
->where('t1.deleted')->eq('0')
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
return $list;
}
/**
* Get a ci job by id.
*
* @param int $id
* @access public
* @return object
*/
public function getJobByID($id)
{
$jenkins = $this->dao->select('*')->from(TABLE_INTEGRATION)->where('id')->eq($id)->fetch();
return $jenkins;
}
/**
* Create a ci job.
*
* @access public
* @return bool
*/
public function createJob()
{
$job = fixer::input('post')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->remove('repoType')
->get();
$this->dao->insert(TABLE_INTEGRATION)->data($job)
->batchCheck($this->config->job->create->requiredFields, 'notempty')
->batchCheckIF($job->triggerType === 'schedule' && $job->scheduleType == 'cron', "cronExpression", 'notempty')
->batchCheckIF($job->triggerType === 'schedule' && $job->scheduleType == 'custom', "scheduleDay,scheduleTime,scheduleInterval", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnFolder", 'notempty')
->autoCheck()
->exec();
$jobId = $this->dao->lastInsertID();
if($job->triggerType =='schedule')
{
$arr = explode(":", $job->scheduleTime);
$hour = $arr[0];
$min = $arr[1];
if($job->scheduleDay == 'everyDay')
{
$days = '1-7';
}
elseif($job->scheduleDay == 'workDay')
{
$days = '1-5';
}
$cron = (object)array('m' => $min, 'h' => $hour, 'dom' => '*', 'mon' => '*',
'dow' => $days . '/' . $job->scheduleInterval, 'command' => 'moduleName=ci&methodName=exeJob&parm=' . $jobId,
'remark' => ($this->lang->ci->extJob . $jobId), 'type' => 'zentao',
'buildin' => '-1', 'status' => 'normal', 'lastTime' => '0000-00-00 00:00:00');
$this->dao->insert(TABLE_CRON)->data($cron)->exec();
}
return true;
}
/**
* Update a ci job.
*
* @param int $id
* @access public
* @return bool
*/
public function updateJob($id)
{
$job = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::now())
->remove('repoType')
->get();
$this->dao->update(TABLE_INTEGRATION)->data($job)
->batchCheck($this->config->job->edit->requiredFields, 'notempty')
->batchCheckIF($job->triggerType === 'schedule' && $job->scheduleType == 'cron', "cronExpression", 'notempty')
->batchCheckIF($job->triggerType === 'schedule' && $job->scheduleType == 'custom', "scheduleDay,scheduleTime,scheduleInterval", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnFolder", 'notempty')
->autoCheck()
->where('id')->eq($id)
->exec();
if ($job->triggerType === 'schedule')
{
$command = 'moduleName=ci&methodName=exeJob&parm=' . $id;
$arr = explode(":", $job->scheduleTime);
$hour = $arr[0];
$min = $arr[1];
if($job->scheduleDay == 'everyDay')
{
$days = '1-7';
}
elseif($job->scheduleDay == 'workDay')
{
$days = '2-6';
}
$this->dao->update(TABLE_CRON)
->set('m')->eq($min)
->set('h')->eq($hour)
->set('dom')->eq('*')
->set('mon')->eq('*')
->set('dow')->eq($days . '/' . $job->scheduleInterval)
->set('lastTime')->eq('0000-00-00 00:00:00')
->where('command')->eq($command)->exec();
}
return true;
}
/**
* Execute ci job.
*
* @param int $id
* @access public
* @return bool
*/
public function exeJob($jobID)
{
$job = $this->dao->select('job.id jobId, job.name jobName, job.repo, job.jenkinsJob, jenkins.name jenkinsName,jenkins.serviceUrl,jenkins.account,jenkins.token,jenkins.password')
->from(TABLE_INTEGRATION)->alias('job')
->leftJoin(TABLE_JENKINS)->alias('jenkins')->on('job.jenkins=jenkins.id')
->where('job.id')->eq($jobID)
->fetch();
if (!$job) return false;
$jenkinsServer = $po->serviceUrl;
$jenkinsUser = $po->account;
$jenkinsTokenOrPassword = $po->token ? $po->token : base64_decode($po->password);
$r = '://' . $jenkinsUser . ':' . $jenkinsTokenOrPassword . '@';
$jenkinsServer = str_replace('://', $r, $jenkinsServer);
$buildUrl = sprintf('%s/job/%s/build/api/json', $jenkinsServer, $po->jenkinsJob);
$po->queueItem = $this->sendBuildRequest($buildUrl);
$this->saveBuild($po);
return !dao::isError();
}
/**
* Get jenkins build list.
*
* @param int $jobID
* @param string $orderBy
* @param object $pager
* @param bool $decode
* @access public
* @return array
*/
public function listBuild($jobID, $orderBy = 'id_desc', $pager = null, $decode = true)
{
$list = $this->dao->
select('build.id, build.name, build.status, build.createdDate, job.triggerType, repo.name repoName, jenkins.name as jenkinsName')
->from(TABLE_COMPILE)->alias('build')
->leftJoin(TABLE_INTEGRATION)->alias('job')->on('build.cijob=job.id')
->leftJoin(TABLE_REPO)->alias('repo')->on('job.repo=repo.id')
->leftJoin(TABLE_JENKINS)->alias('jenkins')->on('job.jenkins=jenkins.id')
->where('build.deleted')->eq('0')
->andWhere('build.cijob')->eq($jobID)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
return $list;
}
/**
* Get jenkins build logs.
*
* @param int $buildID
* @access public
* @return array
*/
public function getBuildByID($buildID)
{
$build = $this->dao->select('*')->from(TABLE_COMPILE)->where('id')->eq($buildID)->fetch();
return $build;
}
/**
* Save build to db.
*
* @param object $job
* @access public
* @return bool
*/
public function saveBuild($job)
{
$build = new stdClass();
$build->cijob = $job->jobId;
$build->name = $job->jobName;
$build->queueItem = $job->queueItem;
$build->status = $job->queueItem ? 'created' : 'create_fail';
$build->createdBy = $this->app->user->account;
$build->createdDate = helper::now();
$this->dao->insert(TABLE_COMPILE)->data($build)->exec();
$repoID = $this->session->repoID;
$moduleName = $this->app->getModuleName();
foreach($this->lang->{$moduleName}->menu as $key => $menu) common::setMenuVars($this->lang->{$moduleName}->menu, $key, $repoID);
$this->lang->{$moduleName}->menuOrder = $this->lang->ci->menuOrder;
}
/**
@@ -264,17 +41,18 @@ class ciModel extends model
->andWhere('build.createdDate')->gt(date(DT_DATETIME1, strtotime("-1 day")))
->fetchAll();
foreach($pos as $po) {
$jenkinsServer = $po->serviceUrl;
$jenkinsUser = $po->account;
$jenkinsTokenOrPassword = $po->token ? $po->token : base64_decode($po->password);
foreach($pos as $po)
{
$jenkinsServer = $po->serviceUrl;
$jenkinsUser = $po->account;
$jenkinsPassword = $po->token ? $po->token : base64_decode($po->password);
$r = '://' . $jenkinsUser . ':' . $jenkinsTokenOrPassword . '@';
$jenkinsServer = str_replace('://', $r, $jenkinsServer);
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsTokenOrPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $po->queueItem);
$response = common::http($queueUrl);
if (strripos($response,"404") > -1)
if(strripos($response, "404") > -1)
{ // queue expired, use another api
$infoUrl = sprintf('%s/job/%s/%s/api/json', $jenkinsServer, $po->jenkinsJob, $po->queueItem);
$response = common::http($infoUrl);
@@ -287,20 +65,25 @@ class ciModel extends model
$logs = json_decode($response);
$this->dao->update(TABLE_COMPILE)->set('logs')->eq($response)->where('id')->eq($po->id)->exec();
} else
{
}
else
{
$queueInfo = json_decode($response);
if (!empty($queueInfo->executable)) {
if(!empty($queueInfo->executable))
{
$buildUrl = $queueInfo->executable->url . 'api/json?pretty=true';
$buildUrl = str_replace('://', $r, $buildUrl);
$response = common::http($buildUrl);
$buildInfo = json_decode($response);
if ($buildInfo->building) {
if($buildInfo->building)
{
$this->updateBuildStatus($po, 'building');
} else {
}
else
{
$result = strtolower($buildInfo->result);
$this->updateBuildStatus($po, $result);
@@ -332,47 +115,20 @@ class ciModel extends model
$this->dao->update(TABLE_INTEGRATION)
->set('lastExec')->eq(helper::now())
->set('lastStatus')->eq($status)
->where('id')->eq($build->cijob)->exec();
->where('id')->eq($build->cijob)
->exec();
}
/**
* @param $url
* @return false|mixed|string
*/
public function sendBuildRequest($url) // not to use common http
{
if(!extension_loaded('curl')) return json_encode(array('result' => 'fail', 'message' => $this->lang->error->noCurlExt));
public function sendRequest($url, $data)
{
if(!empty($data->PARAM_TAG)) $data->PARAM_REVISION = '';
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl, CURLOPT_USERAGENT, 'Sae T OAuth2 v0.1');
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
$headers[] = "API-RemoteIP: " . $_SERVER['REMOTE_ADDR'];
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE);
curl_setopt ($curl , CURLOPT_HEADER, 1 );
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, new stdClass());
$response = curl_exec($curl);
$errors = curl_error($curl);
curl_close($curl);
if ( preg_match ( "!Location: .*item/(.*)/!", $response , $matches ) ) {
return $matches[1];
}
return '';
}
$response = common::http($url, $data, true);
if(preg_match("!Location: .*item/(.*)/!", $response, $matches)) return $matches[1];
return '';
}
}
-83
View File
@@ -1,83 +0,0 @@
<?php
/**
* The browse view file of jenkins build 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->inlink('browsejob', ""), "<span class='text'>{$lang->ci->task}</span>", '', "class='btn btn-link" . ('browseJob' == $method ? ' btn-active-text' : '') . "'");
echo html::a($this->inlink('browsebuild', ""), "<span class='text'>{$lang->ci->history}</span>", '', "class='btn btn-link" . ('browseBuild' == $method ? ' btn-active-text' : '') . "'");
?>
</div>
<div class="btn-toolbar pull-right">
<?php
if(common::hasPriv('ci', 'createJob')) {
common::printLink('ci', 'createJob', "", "<i class='icon icon-plus'></i> " . $lang->ci->create, '', "class='btn btn-primary'");
}
?>
</div>
</div>
<div id='mainContent' class='main-row'>
<div class='main-col main-content'>
<form class='main-table' id='ajaxForm' method='post'>
<table id='buildList' class='table has-sort-head table-fixed'>
<thead>
<tr>
<?php $vars = "jobID={$job->id}&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='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->job->name); ?></th>
<th class='w-200px text-left'><?php echo $lang->ci->repo; ?></th>
<th class='w-200px text-left'><?php echo $lang->ci->jenkins; ?></th>
<th class='w-200px text-left'><?php echo $lang->job->triggerType; ?></th>
<th class='w-150px text-left'><?php common::printOrderLink('status', $orderBy, $vars, $lang->job->buildStatus); ?></th>
<th class='text-left'><?php common::printOrderLink('createdDate', $orderBy, $vars, $lang->job->buildTime); ?></th>
<th class='w-100px c-actions-4'><?php echo $lang->actions; ?></th>
</tr>
</thead>
<tbody>
<?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 $build->jenkinsName; ?></td>
<td class='text' title='<?php echo $lang->job->triggerTypeList[$build->triggerType]; ?>'>
<?php echo $lang->job->triggerTypeList[$build->triggerType]; ?>
</td>
<td class='text' title='<?php echo $lang->job->buildStatusList[$build->status]; ?>'>
<?php echo $lang->job->buildStatusList[$build->status]; ?>
</td>
<td class='text' title='<?php echo $build->createDate; ?>'><?php echo $build->createdDate; ?></td>
<td class='c-actions text-center'>
<?php
common::printIcon('ci', 'viewBuildLogs', "buildID=$id", '', 'list', 'file-text',
'', '', '', '', $lang->job->viewLogs);
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($buildList): ?>
<div class='table-footer'><?php $pager->show('rignt', 'pagerjs'); ?></div>
<?php endif; ?>
</form>
</div>
</div>
<?php include '../../common/view/footer.html.php'; ?>
-94
View File
@@ -1,94 +0,0 @@
<?php
/**
* The browse view file of ci 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 ci
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('confirmDelete', $lang->job->confirmDelete); ?>
<div id="mainMenu" class="clearfix">
<div class="btn-toolbar pull-left">
<?php
echo html::a($this->inlink('browsejob', ""), "<span class='text'>{$lang->ci->task}</span>", '', "class='btn btn-link" . ('browseJob' == $method ? ' btn-active-text' : '') . "'");
echo html::a($this->inlink('browsebuild', ""), "<span class='text'>{$lang->ci->history}</span>", '', "class='btn btn-link" . ('browseBuild' == $method ? ' btn-active-text' : '') . "'");
?>
</div>
<div class="btn-toolbar pull-right">
<?php
if(common::hasPriv('ci', 'createJob')) {
common::printLink('ci', 'createJob', "", "<i class='icon icon-plus'></i> " . $lang->ci->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>
<?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='w-200px text-left'>
<?php common::printOrderLink('name', $orderBy, $vars, $lang->job->name); ?></th>
<th class='w-200px text-left'>
<?php common::printOrderLink('repo', $orderBy, $vars, $lang->ci->repo); ?></th>
<th class='w-150px text-left'><?php echo $lang->job->triggerType; ?></th>
<th class='w-200px text-left'>
<?php common::printOrderLink('jenkins', $orderBy, $vars, $lang->job->jenkins); ?></th>
<th class='w-200px text-left'><?php echo $lang->job->jenkinsJob; ?></th>
<th class='text-left'><?php echo $lang->job->lastExe; ?></th>
<th class='w-120px c-actions-4'><?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>
<td class='text' title='<?php echo $lang->job->triggerTypeList[$job->triggerType]; ?>'>
<?php echo $lang->job->triggerTypeList[$job->triggerType]; ?></td>
<td class='text' title='<?php echo $job->jenkinsName; ?>'><?php echo $job->jenkinsName; ?></td>
<td class='text' title='<?php echo $job->jenkinsJob; ?>'><?php echo $job->jenkinsJob; ?></td>
<td class='text' title='<?php echo $lang->job->lastBuild; ?>'>
<?php if ($job->lastStatus) echo $lang->job->buildStatusList[$job->lastStatus] . $lang->ci->at . $job->lastExec; ?>
</td>
<td class='c-actions text-center'>
<?php
common::printIcon('ci', 'browseBuild', "jobID=$id", '', 'list', 'file-text');
common::printIcon('ci', 'editJob', "jobID=$id", '', 'list', 'edit');
if (common::hasPriv('ci', 'deleteJob'))
{
$deleteURL = $this->createLink('ci', 'deleteJob', "jobID=$id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"jobList\", confirmDelete)", '<i class="icon-trash"></i>', '', "title='{$lang->job->delete}' class='btn'");
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($jobList): ?>
<div class='table-footer'><?php $pager->show('rignt', 'pagerjs'); ?></div>
<?php endif; ?>
</form>
</div>
<?php include '../../common/view/footer.html.php'; ?>
-33
View File
@@ -1,33 +0,0 @@
<?php
/**
* The browse view file of jenkins build 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'>
<div class="page-title">
<strong>
<?php echo $lang->job->viewLogs; ?>
</strong>
</div>
</div>
<div class="btn-toolbar pull-right">
<?php echo html::a(helper::createLink('ci', "browseBuild", "jobId=$build->cijob"), "<i class='icon icon-back icon-sm'></i> ". $lang->goback, '', "class='btn btn-secondary'");?>
</div>
</div>
<div id='mainContent' class='main-row'>
<div class='main-col main-content'>
<?php echo $logs; ?>
</div>
</div>
<?php include '../../common/view/footer.html.php'; ?>
+11 -5
View File
@@ -335,14 +335,18 @@ $lang->caselib->menu->caselib = array('link' => '用例库|caselib|browse|libI
$lang->ci = new stdclass();
$lang->ci->menu = new stdclass();
$lang->ci->menu->browse = array('link' =>'浏览|repo|browse|repoID=%s', 'alias' => 'diff,view,revision,log,blame,showsynccomment');
$lang->ci->menu->job = array('link' =>'构建|ci|browsejob', 'alias' => 'createjob,editjob,browsebuild,viewbuildlogs');
$lang->ci->menu->job = array('link' =>'构建|integration|browse', 'subModule' => 'compile,integration');
$lang->ci->menu->maintain = array('link' =>'版本库|repo|maintain', 'alias' => 'create,edit');
$lang->ci->menu->jenkins = array('link' =>'Jenkins|jenkins|browse', 'alias' => 'create,edit');
$lang->repo = new stdclass();
$lang->jenkins = new stdclass();
$lang->repo->menu = $lang->ci->menu;
$lang->jenkins->menu = $lang->ci->menu;
$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->doc = new stdclass();
@@ -484,6 +488,8 @@ $lang->menugroup->message = 'admin';
$lang->menugroup->repo = 'ci';
$lang->menugroup->jenkins = 'ci';
$lang->menugroup->compile = 'ci';
$lang->menugroup->integration = 'ci';
/* 错误提示信息。*/
$lang->error = new stdclass();
+2 -1
View File
@@ -1820,7 +1820,7 @@ EOD;
* @access public
* @return string
*/
public static function http($url, $data = null)
public static function http($url, $data = null, $optHeader = false)
{
global $lang, $app;
if(!extension_loaded('curl')) return json_encode(array('result' => 'fail', 'message' => $lang->error->noCurlExt));
@@ -1841,6 +1841,7 @@ EOD;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE);
if($optHeader) curl_setopt($curl, CURLOPT_HEADER, true);
if(!empty($data))
{
curl_setopt($curl, CURLOPT_POST, true);
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* The control file of compile 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 compile
* @version $Id$
* @link http://www.zentao.net
*/
class compile extends control
{
/**
* Construct
*
* @param string $moduleName
* @param string $methodName
* @access public
* @return void
*/
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
$this->loadModel('ci')->setMenu();
}
/**
* Browse jenkins build.
*
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
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->job . $this->lang->colon . $this->lang->compile->browse;
$this->view->position[] = html::a($this->createLink('integration', 'browse'), $this->lang->ci->job);
$this->view->position[] = $this->lang->compile->browse;
$this->view->buildList = $this->compile->getList($jobID, $orderBy, $pager);
$this->view->job = $this->loadModel('integration')->getByID($jobID);
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->display();
}
/**
* View jenkins build logs.
*
* @param int $buildID
* @access public
* @return void
*/
public function logs($buildID)
{
$build = $this->compile->getByID($buildID);
$this->view->logs = str_replace("\r\n","<br />", $build->logs);
$this->view->build = $build;
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->compile->logs;
$this->view->position[] = html::a($this->createLink('integration', 'browse'), $this->lang->ci->job);
$this->view->position[] = html::a($this->createLink('compile', 'browse', "jobID=" . $build->cijob), $this->lang->compile->browse);
$this->view->position[] = $this->lang->compile->logs;
$this->display();
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
$lang->compile->browse = 'Build Histories';
$lang->compile->logs = 'Build Logs';
$lang->compile->id = 'ID';
$lang->compile->name = 'Name';
$lang->compile->status = 'Build Status';
$lang->compile->time = 'Build Time';
$lang->compile->statusList['success'] = 'Success';
$lang->compile->statusList['fail'] = 'Fail';
$lang->compile->statusList['created'] = 'Created';
$lang->compile->statusList['building'] = 'Building';
$lang->compile->statusList['create_fail'] = 'Fail to create';
$lang->compile->statusList['timeout'] = 'Exec Timeout';
+15
View File
@@ -0,0 +1,15 @@
<?php
$lang->compile->browse = '构建历史';
$lang->compile->logs = '构建日志';
$lang->compile->id = 'ID';
$lang->compile->name = '名称';
$lang->compile->status = '构建状态';
$lang->compile->time = '构建时间';
$lang->compile->statusList['success'] = '成功';
$lang->compile->statusList['fail'] = '失败';
$lang->compile->statusList['created'] = '新建';
$lang->compile->statusList['building'] = '构建中';
$lang->compile->statusList['create_fail'] = '创建失败';
$lang->compile->statusList['timeout'] = '执行超时';
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* The model file of compile 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 compile
* @version $Id$
* @link http://www.zentao.net
*/
class compileModel extends model
{
/**
* Get build list.
*
* @param int $jobID
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($jobID, $orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('t1.id, t1.name, t1.status, t1.createdDate, t2.triggerType, t3.name as repoName, t4.name as jenkinsName')->from(TABLE_COMPILE)->alias('t1')
->leftJoin(TABLE_INTEGRATION)->alias('t2')->on('t1.cijob=t2.id')
->leftJoin(TABLE_REPO)->alias('t3')->on('t2.repo=t3.id')
->leftJoin(TABLE_JENKINS)->alias('t4')->on('t2.jenkins=t4.id')
->where('t1.deleted')->eq('0')
->andWhere('t1.cijob')->eq($jobID)
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
}
/**
* Get by id
*
* @param int $buildID
* @access public
* @return object
*/
public function getByID($buildID)
{
return $this->dao->select('*')->from(TABLE_COMPILE)->where('id')->eq($buildID)->fetch();
}
/**
* Save build by job
*
* @param object $job
* @access public
* @return void
*/
public function saveBuild($job)
{
$build = new stdClass();
$build->cijob = $job->jobId;
$build->name = $job->jobName;
$build->queueItem = $job->queueItem;
$build->status = $job->queueItem ? 'created' : 'create_fail';
$build->createdBy = $this->app->user->account;
$build->createdDate = helper::now();
$this->dao->insert(TABLE_COMPILE)->data($build)->exec();
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
/**
* The browse view file of compile 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 compile
* @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->task}</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>
</div>
<div id='mainContent'>
<form class='main-table' id='ajaxForm' method='post'>
<table id='buildList' class='table has-sort-head table-fixed'>
<thead>
<tr>
<?php $vars = "jobID={$job->id}&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='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->compile->name);?></th>
<th class='w-200px text-left'><?php echo $lang->integration->repo;?></th>
<th class='w-200px text-left'><?php echo $lang->integration->jenkins;?></th>
<th class='w-200px text-left'><?php echo $lang->integration->triggerType;?></th>
<th class='w-150px text-left'><?php common::printOrderLink('status', $orderBy, $vars, $lang->compile->status);?></th>
<th class='text-left'><?php common::printOrderLink('createdDate', $orderBy, $vars, $lang->compile->time);?></th>
<th class='w-100px c-actions-4'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?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 $build->jenkinsName; ?></td>
<?php $triggerType = zget($lang->integration->triggerTypeList, $build->triggerType);?>
<td class='text' title='<?php echo $triggerType;?>'><?php echo $triggerType;?></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->createDate; ?>'><?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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if($buildList):?>
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
<?php endif; ?>
</form>
</div>
<?php include '../../common/view/footer.html.php'; ?>
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* The browse view file of compile 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 compile
* @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'>
<div class="page-title">
<strong><?php echo $lang->compile->logs;?></strong>
</div>
</div>
<div class="btn-toolbar pull-right">
<?php echo html::a(helper::createLink('compile', "browse", "jobId=$build->cijob"), "<i class='icon icon-back icon-sm'></i> ". $lang->goback, '', "class='btn btn-secondary'");?>
</div>
</div>
<div id='mainContent'>
<div class='main-content'><?php echo $logs;?></div>
</div>
<?php include '../../common/view/footer.html.php'; ?>
+6
View File
@@ -0,0 +1,6 @@
<?php
$config->integration = new stdclass();
$config->integration->create = new stdclass();
$config->integration->edit = new stdclass();
$config->integration->create->requiredFields = 'name,repo,jenkins,jenkinsJob,triggerType';
$config->integration->edit->requiredFields = 'name,repo,jenkins,jenkinsJob,triggerType';
+169
View File
@@ -0,0 +1,169 @@
<?php
/**
* The control file of integration 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
* @version $Id$
* @link http://www.zentao.net
*/
class integration extends control
{
/**
* Construct
*
* @param string $moduleName
* @param string $methodName
* @access public
* @return void
*/
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct($moduleName, $methodName);
$this->loadModel('ci')->setMenu();
}
/**
* Browse ci job.
*
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->app->loadLang('compile');
$this->view->jobList = $this->integration->getList($orderBy, $pager);
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->integration->browse;
$this->view->position[] = $this->lang->ci->job;
$this->view->position[] = $this->lang->integration->browse;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->display();
}
/**
* Create a ci job.
*
* @access public
* @return void
*/
public function create()
{
if($_POST)
{
$this->integration->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->job . $this->lang->colon . $this->lang->integration->create;
$this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
$this->view->position[] = $this->lang->integration->create;
$repoList = $this->loadModel('repo')->getAllRepos();
$repoPairs = array(0 => '');
$repoTypes = array();
foreach($repoList as $repo)
{
$repoPairs[$repo->id] = $repo->name;
$repoTypes[$repo->id] = $repo->SCM;
}
$this->view->repoPairs = $repoPairs;
$this->view->repoTypes = $repoTypes;
$this->view->jenkinsList = $this->loadModel('jenkins')->getPairs();
$this->display();
}
/**
* Edit a ci job.
*
* @param int $id
* @access public
* @return void
*/
public function edit($id)
{
$job = $this->integration->getByID($id);
if($_POST)
{
$this->integration->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->app->loadLang('action');
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->integration->edit;
$this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
$this->view->position[] = $this->lang->integration->edit;
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
$repoList = $this->loadModel('repo')->getAllRepos();
$repoPairs = array(0 => '', $repo->id => $repo->name);
$repoTypes[$repo->id] = $repo->SCM;
foreach($repoList as $repo)
{
$repoPairs[$repo->id] = $repo->name;
$repoTypes[$repo->id] = $repo->SCM;
}
$this->view->repoPairs = $repoPairs;
$this->view->repoTypes = $repoTypes;
$this->view->job = $job;
$this->view->jenkinsList = $this->loadModel('jenkins')->getPairs();
$this->display();
}
/**
* Delete a ci job.
*
* @param int $id
* @access public
* @return void
*/
public function delete($id, $confirm = 'no')
{
if($confirm != 'yes')
{
die(js::confirm($this->lang->integration->confirmDelete, inlink('delete', "jobID=$id&confirm=yes")));
}
$this->integration->delete(TABLE_INTEGRATION, $id);
$command = 'moduleName=ci&methodName=exe&parm=' . $id;
$this->dao->delete()->from(TABLE_CRON)->where('command')->eq($command)->exec();
die(js::reload('parent'));
}
/**
* Exec a ci job.
*
* @param int $id
* @access public
* @return void
*/
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'));
$this->send(array('result' => 'success'));
}
}
@@ -69,8 +69,8 @@ $(function()
triggerTypeChanged(triggerType);
});
function exeJob(id) {
var link = createLink('ci', 'exeJob', 'id=' + id);
function execJob(id) {
var link = createLink('integration', 'exec', 'id=' + id);
$.ajax({
type:"POST",
url: link,
+46
View File
@@ -0,0 +1,46 @@
<?php
$lang->integration->browse = 'Browse Integration';
$lang->integration->create = 'Create Integration';
$lang->integration->edit = 'Edit Integration';
$lang->integration->execNow = 'Execute now';
$lang->integration->delete = 'Delete Integration';
$lang->integration->confirmDelete = 'Do you want to delete this Build?';
$lang->integration->id = 'ID';
$lang->integration->name = 'Name';
$lang->integration->repo = 'Repo';
$lang->integration->svnFolder = 'SVN Tag Watch Path';
$lang->integration->jenkins = 'Jenkins Server';
$lang->integration->buildType = 'Build Type';
$lang->integration->jenkinsJob = 'Jenkins Task';
$lang->integration->triggerType = 'Trigger';
$lang->integration->scheduleType = 'Schedule';
$lang->integration->cronExpression = 'Cron Expression';
$lang->integration->custom = 'Custom';
$lang->integration->at = 'executed on';
$lang->integration->time = 'Time';
$lang->integration->exec = 'Execute';
$lang->integration->scheduleInterval = 'Every';
$lang->integration->day = 'days';
$lang->integration->lastExec = 'Last Executed';
$lang->integration->scheduleTime = 'Time';
$lang->integration->example = 'e.g.';
$lang->integration->tagEx = 'build_#15, to build Jenkins job that id is 15.';
$lang->integration->commitEx = 'start build #15, to build Jenkins job that id is 15.';
$lang->integration->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
$lang->integration->dayTypeList['workDay'] = 'Weekdays';
$lang->integration->dayTypeList['everyDay'] = 'Every Day';
$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';
$lang->integration->scheduleTypeList['cron'] = 'Crontab';
$lang->integration->scheduleTypeList['custom'] = 'Custom';
+46
View File
@@ -0,0 +1,46 @@
<?php
$lang->integration->browse = '浏览构建任务';
$lang->integration->create = '创建构建任务';
$lang->integration->edit = '编辑构建任务';
$lang->integration->execNow = '立即执行';
$lang->integration->delete = '删除构建任务';
$lang->integration->confirmDelete = '确认删除该构建任务吗?';
$lang->integration->id = 'ID';
$lang->integration->name = '名称';
$lang->integration->repo = '代码库';
$lang->integration->svnFolder = 'SVN Tag监控路径';
$lang->integration->jenkins = 'Jenkins服务';
$lang->integration->buildType = '构建类型';
$lang->integration->jenkinsJob = 'Jenkins任务名';
$lang->integration->triggerType = '触发方式';
$lang->integration->scheduleType = '时间计划';
$lang->integration->cronExpression = 'Cron表达式';
$lang->integration->custom = '自定义';
$lang->integration->at = '在';
$lang->integration->time = '时间';
$lang->integration->exec = '执行';
$lang->integration->scheduleInterval = '每隔';
$lang->integration->day = '天';
$lang->integration->lastExec = '最后执行';
$lang->integration->scheduleTime = '时间';
$lang->integration->example = '举例';
$lang->integration->tagEx = 'build_#15,其中15为Jenkins任务编号';
$lang->integration->commitEx = 'start build #15,其中15为Jenkins任务编号';
$lang->integration->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
$lang->integration->dayTypeList['workDay'] = '工作日';
$lang->integration->dayTypeList['everyDay'] = '每天';
$lang->integration->buildTypeList['build'] = '仅构建';
$lang->integration->buildTypeList['buildAndDeploy'] = '构建部署';
$lang->integration->buildTypeList['buildAndTest'] = '构建测试';
$lang->integration->triggerTypeList['tag'] = '打标签';
$lang->integration->triggerTypeList['commit'] = '代码提交注释';
$lang->integration->triggerTypeList['schedule'] = '定时计划';
$lang->integration->scheduleTypeList['cron'] = 'Crontab';
$lang->integration->scheduleTypeList['custom'] = '自定义';
+188
View File
@@ -0,0 +1,188 @@
<?php
/**
* The model file of integration 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
* @version $Id$
* @link http://www.zentao.net
*/
class integrationModel extends model
{
/**
* Get by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
return $this->dao->select('*')->from(TABLE_INTEGRATION)->where('id')->eq($id)->fetch();
}
/**
* Get integration list.
*
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
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')
->leftJoin(TABLE_REPO)->alias('t2')->on('t1.repo=t2.id')
->leftJoin(TABLE_JENKINS)->alias('t3')->on('t1.jenkins=t3.id')
->where('t1.deleted')->eq('0')
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
}
/**
* Create integration
*
* @access public
* @return void
*/
public function create()
{
$integration = fixer::input('post')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->remove('repoType')
->get();
$this->dao->insert(TABLE_INTEGRATION)->data($integration)
->batchCheck($this->config->integration->create->requiredFields, 'notempty')
->batchCheckIF($integration->triggerType === 'schedule' && $integration->scheduleType == 'cron', "cronExpression", 'notempty')
->batchCheckIF($integration->triggerType === 'schedule' && $integration->scheduleType == 'custom', "scheduleDay,scheduleTime,scheduleInterval", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnFolder", 'notempty')
->autoCheck()
->exec();
$integrationId = $this->dao->lastInsertID();
if($integration->triggerType =='schedule')
{
$arr = explode(":", $integration->scheduleTime);
$hour = $arr[0];
$min = $arr[1];
if($integration->scheduleDay == 'everyDay')
{
$days = '1-7';
}
elseif($integration->scheduleDay == 'workDay')
{
$days = '1-5';
}
$cron = (object)array('m' => $min, 'h' => $hour, 'dom' => '*', 'mon' => '*',
'dow' => $days . '/' . $integration->scheduleInterval, 'command' => 'moduleName=ci&methodName=exeJob&parm=' . $integrationId,
'remark' => ($this->lang->ci->extJob . $integrationId), 'type' => 'zentao',
'buildin' => '-1', 'status' => 'normal', 'lastTime' => '0000-00-00 00:00:00');
$this->dao->insert(TABLE_CRON)->data($cron)->exec();
}
return true;
}
/**
* Update integration
*
* @param int $id
* @access public
* @return void
*/
public function update($id)
{
$integration = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::now())
->remove('repoType')
->get();
$this->dao->update(TABLE_INTEGRATION)->data($integration)
->batchCheck($this->config->integration->edit->requiredFields, 'notempty')
->batchCheckIF($integration->triggerType === 'schedule' && $integration->scheduleType == 'cron', "cronExpression", 'notempty')
->batchCheckIF($integration->triggerType === 'schedule' && $integration->scheduleType == 'custom', "scheduleDay,scheduleTime,scheduleInterval", 'notempty')
->batchCheckIF($this->post->repoType == 'Subversion', "svnFolder", 'notempty')
->autoCheck()
->where('id')->eq($id)
->exec();
if ($integration->triggerType === 'schedule')
{
$command = 'moduleName=ci&methodName=exeJob&parm=' . $id;
$arr = explode(":", $integration->scheduleTime);
$hour = $arr[0];
$min = $arr[1];
if($integration->scheduleDay == 'everyDay')
{
$days = '1-7';
}
elseif($integration->scheduleDay == 'workDay')
{
$days = '2-6';
}
$this->dao->update(TABLE_CRON)
->set('m')->eq($min)
->set('h')->eq($hour)
->set('dom')->eq('*')
->set('mon')->eq('*')
->set('dow')->eq($days . '/' . $integration->scheduleInterval)
->set('lastTime')->eq('0000-00-00 00:00:00')
->where('command')->eq($command)->exec();
}
return true;
}
/**
* Execute integration
*
* @param int $integrationID
* @access public
* @return bool
*/
public function exec($integrationID)
{
$integration = $this->dao->select('t1.id as jobId,t1.name as jobName,t1.repo,t1.jenkinsJob,t2.name as jenkinsName,t2.serviceUrl,t2.account,t2.token,t2.password')
->from(TABLE_INTEGRATION)->alias('t1')
->leftJoin(TABLE_JENKINS)->alias('t2')->on('t1.jenkins=t2.id')
->where('t1.id')->eq($integrationID)
->fetch();
if (!$integration) return false;
$jenkinsServer = $integration->serviceUrl;
$jenkinsUser = $integration->account;
$jenkinsPassword = $integration->token ? $integration->token : base64_decode($integration->password);
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$buildUrl = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $integration->jenkinsJob);
$data = new stdClass();
// TODO: 将参数加入$data,代码完成后删除注释
// PARAM_TAG:git tag name or svn tag url
// PARAM_REVISION:git revision string or svn revision number
$data->PARAM_TAG = "tag111";
$data->PARAM_REVISION = "6c3a7bf931855842e261c7991bb143c1e0c3fb19";
$integration->queueItem = $this->loadModel('ci')->sendRequest($buildUrl, $data);
$this->loadModel('compile')->saveBuild($integration);
return !dao::isError();
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* The browse view file of ci 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 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->task}</span>", '', "class='btn btn-link btn-active-text'");?>
</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>
<?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='w-200px 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-150px text-left'><?php echo $lang->integration->triggerType;?></th>
<th class='w-200px text-left'><?php common::printOrderLink('jenkins', $orderBy, $vars, $lang->integration->jenkins);?></th>
<th class='w-200px text-left'><?php echo $lang->integration->jenkinsJob;?></th>
<th class='text-left'><?php echo $lang->integration->lastExec;?></th>
<th class='w-120px c-actions-4'><?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);?>
<td class='text' title='<?php echo $triggerType;?>'><?php echo $triggerType;?></td>
<td class='text' title='<?php echo $job->jenkinsName; ?>'><?php echo $job->jenkinsName; ?></td>
<td class='text' title='<?php echo $job->jenkinsJob; ?>'><?php echo $job->jenkinsJob; ?></td>
<td class='text'><?php if($job->lastStatus) echo zget($lang->compile->statusList, $job->lastStatus) . $lang->ci->at . $job->lastExec;?></td>
<td class='c-actions text-center'>
<?php
common::printIcon('compile', 'browse', "jobID=$id", '', 'list', 'file-text');
common::printIcon('integration', 'edit', "jobID=$id", '', 'list', 'edit');
if(common::hasPriv('integration', 'delete')) echo html::a($this->createLink('integration', 'delete', "jobID=$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'; ?>
@@ -1,11 +1,11 @@
<?php
/**
* The create view file of ci job module of ZenTaoPMS.
* The create 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 job
* @package integration
* @version $Id$
* @link http://www.zentao.net
*/
@@ -19,51 +19,51 @@
<div class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->job->create; ?></h2>
<h2><?php echo $lang->integration->create; ?></h2>
</div>
<form id='jobForm' method='post' class='form-ajax'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->job->name; ?></th>
<th><?php echo $lang->integration->name; ?></th>
<td class='required'><?php echo html::input('name', '', "class='form-control'"); ?></td>
<td colspan="2" ></td>
</tr>
<tr>
<th><?php echo $lang->ci->repo; ?></th>
<th><?php echo $lang->integration->repo; ?></th>
<td><?php echo html::select('repo', $repoPairs, '', "class='form-control chosen'"); ?></td>
<th class="svn-fields hidden"><?php echo $lang->job->svnFolder; ?></th>
<th class="svn-fields hidden"><?php echo $lang->integration->svnFolder; ?></th>
<td class="svn-fields hidden" id='svnFolderBox'></td>
</tr>
<tr>
<th><?php echo $lang->job->jenkins; ?></th>
<th><?php echo $lang->integration->jenkins; ?></th>
<td><?php echo html::select('jenkins', $jenkinsList, '', "class='form-control chosen'"); ?></td>
<th><?php echo $lang->job->jenkinsJob; ?></th>
<th><?php echo $lang->integration->jenkinsJob; ?></th>
<td><?php echo html::input('jenkinsJob', '', "class='form-control'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->job->triggerType; ?></th>
<td><?php echo html::select('triggerType', $lang->job->triggerTypeList, '', "onchange='triggerTypeChanged(this.value)' class='form-control chosen'"); ?></td>
<th><?php echo $lang->integration->triggerType; ?></th>
<td><?php echo html::select('triggerType', $lang->integration->triggerTypeList, '', "onchange='triggerTypeChanged(this.value)' class='form-control chosen'"); ?></td>
<td colspan="2"></td>
</tr>
<tr class="tag-fields" class="tag-fields">
<th><?php echo $lang->job->example; ?></th>
<td colspan="3"><?php echo $lang->job->tagEx; ?></td>
<th><?php echo $lang->integration->example; ?></th>
<td colspan="3"><?php echo $lang->integration->tagEx; ?></td>
</tr>
<tr class="comment-fields" class="comment-fields">
<th><?php echo $lang->job->example; ?></th>
<td colspan="3"><?php echo $lang->job->commitEx; ?></td>
<th><?php echo $lang->integration->example; ?></th>
<td colspan="3"><?php echo $lang->integration->commitEx; ?></td>
</tr>
<tr class="custom-fields">
<th><?php echo $lang->job->custom; ?></th>
<th><?php echo $lang->integration->custom; ?></th>
<td colspan="3">
<div class="row text-with-input">
<div class="col w-50px"><?php echo $lang->job->scheduleInterval;?></div>
<div class="col w-50px"><?php echo $lang->integration->scheduleInterval;?></div>
<div class="col w-100px"><?php echo html::number('scheduleInterval', '1', "class='form-control'");?></div>
<div class="col w-40px"><?php echo $lang->job->day;?>, </div>
<div class="col <?php echo $this->app->getClientLang() == 'en' ? 'w-100px' : '2-30px'; ?>"><?php echo $lang->job->at;?></div>
<div class="col w-150px"><?php echo html::select('scheduleDay', $lang->job->dayTypeList, '',"class='form-control chosen'");?></div>
<div class="col w-40px"><?php echo $lang->integration->day;?>, </div>
<div class="col <?php echo $this->app->getClientLang() == 'en' ? 'w-100px' : '2-30px'; ?>"><?php echo $lang->integration->at;?></div>
<div class="col w-150px"><?php echo html::select('scheduleDay', $lang->integration->dayTypeList, '',"class='form-control chosen'");?></div>
<div class="col w-100px"><?php echo html::input('scheduleTime', '2:00', "class='form-control form-time time-only' min='1'");?></div>
<div class="col w-120px"><?php echo $lang->job->exe;?>。 </div>
<div class="col w-120px"><?php echo $lang->integration->exec;?>。 </div>
</div>
</td>
</tr>
@@ -1,11 +1,11 @@
<?php
/**
* The edit view file of ci job module of ZenTaoPMS.
* The edit 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 job
* @package integration
* @version $Id$
* @link http://www.zentao.net
*/
@@ -22,51 +22,51 @@
<div class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->job->edit; ?></h2>
<h2><?php echo $lang->integration->edit; ?></h2>
</div>
<form id='jobForm' method='post' class='form-ajax'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->job->name; ?></th>
<th><?php echo $lang->integration->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->ci->repo; ?></th>
<th><?php echo $lang->integration->repo; ?></th>
<td><?php echo html::select('repo', $repoPairs, $job->repo, "class='form-control chosen'"); ?></td>
<th class="svn-fields hidden"><?php echo $lang->job->svnFolder; ?></th>
<th class="svn-fields hidden"><?php echo $lang->integration->svnFolder; ?></th>
<td class="svn-fields hidden" id='svnFolderBox'></td>
</tr>
<tr>
<th><?php echo $lang->job->jenkins; ?></th>
<th><?php echo $lang->integration->jenkins; ?></th>
<td><?php echo html::select('jenkins', $jenkinsList, $job->jenkins, "class='form-control chosen'"); ?></td>
<th><?php echo $lang->job->jenkinsJob; ?></th>
<th><?php echo $lang->integration->jenkinsJob; ?></th>
<td><?php echo html::input('jenkinsJob', $job->jenkinsJob, "class='form-control'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->job->triggerType; ?></th>
<td><?php echo html::select('triggerType', $lang->job->triggerTypeList, $job->triggerType, "onchange='triggerTypeChanged(this.value)' class='form-control chosen'"); ?></td>
<th><?php echo $lang->integration->triggerType; ?></th>
<td><?php echo html::select('triggerType', $lang->integration->triggerTypeList, $job->triggerType, "onchange='triggerTypeChanged(this.value)' class='form-control chosen'"); ?></td>
<td colspan="2"></td>
</tr>
<tr class="tag-fields">
<th><?php echo $lang->job->example; ?></th>
<td colspan="3"><?php echo $lang->job->tagEx; ?></td>
<th><?php echo $lang->integration->example; ?></th>
<td colspan="3"><?php echo $lang->integration->tagEx; ?></td>
</tr>
<tr class="comment-fields">
<th><?php echo $lang->job->example; ?></th>
<td colspan="3"><?php echo $lang->job->commitEx; ?></td>
<th><?php echo $lang->integration->example; ?></th>
<td colspan="3"><?php echo $lang->integration->commitEx; ?></td>
</tr>
<tr class="custom-fields">
<th><?php echo $lang->job->custom; ?></th>
<th><?php echo $lang->integration->custom; ?></th>
<td colspan="3">
<div class="row text-with-input">
<div class="col w-50px"><?php echo $lang->job->scheduleInterval;?></div>
<div class="col w-50px"><?php echo $lang->integration->scheduleInterval;?></div>
<div class="col w-100px"><?php echo html::number('scheduleInterval', $job->scheduleInterval, "class='form-control'");?></div>
<div class="col w-40px"><?php echo $lang->job->day; ?>,&nbsp;&nbsp;</div>
<div class="col <?php echo $this->app->getClientLang() == 'en' ? 'w-100px' : '2-30px'; ?>"><?php echo $lang->job->at;?></div>
<div class="col w-150px"><?php echo html::select('scheduleDay', $lang->job->dayTypeList, $job->scheduleDay,"class='form-control chosen'");?></div>
<div class="col w-40px"><?php echo $lang->integration->day; ?>,&nbsp;&nbsp;</div>
<div class="col <?php echo $this->app->getClientLang() == 'en' ? 'w-100px' : '2-30px'; ?>"><?php echo $lang->integration->at;?></div>
<div class="col w-150px"><?php echo html::select('scheduleDay', $lang->integration->dayTypeList, $job->scheduleDay,"class='form-control chosen'");?></div>
<div class="col w-100px"><?php echo html::input('scheduleTime', $job->scheduleTime, "class='form-control form-time time-only' min='1'");?></div>
<div class="col w-120px"><?php echo $lang->job->exe; ?>.</div>
<div class="col w-120px"><?php echo $lang->integration->exec; ?>.</div>
</div>
</td>
</tr>
@@ -77,7 +77,7 @@
<?php echo html::backButton(); ?>
<?php echo html::hidden('repoType', zget($repoTypes, $job->repo, 'Git'));?>
&nbsp;
<?php echo html::commonButton($lang->job->exeNow, "onclick=exeJob($job->id) data-tip-class='tooltip-success'", "btn btn-info exe-job-button");?>
<?php echo html::commonButton($lang->integration->execNow, "onclick=execJob($job->id) data-tip-class='tooltip-success'", "btn btn-info exe-job-button");?>
</td>
</tr>
</table>
+4 -8
View File
@@ -99,16 +99,12 @@ class jenkinsModel extends model
/**
* list jenkins for ci task edit
*
* @return mixed
* @return array
*/
public function listForSelection($whr)
public function getPairs()
{
$repos = $this->dao->select('id, name')->from(TABLE_JENKINS)
->where('deleted')->eq('0')
->beginIF(!empty($whr))->andWhere('(' . $whr . ')')->fi()
->orderBy('id')
->fetchPairs();
$repos[''] = '';
$repos = $this->dao->select('id,name')->from(TABLE_JENKINS)->where('deleted')->eq('0')->orderBy('id')->fetchPairs('id', 'name');
$repos = array('' => '') + $repos;
return $repos;
}
}
-16
View File
@@ -916,22 +916,6 @@ class repoModel extends model
return $replaceLines;
}
/**
* list repos for jenkins job edit
*
* @return mixed
*/
public function listForSelection($whr)
{
$repos = $this->dao->select('id, name')->from(TABLE_REPO)
->where('deleted')->eq('0')
->beginIF(!empty(whr))->andWhere('(' . $whr . ')')->fi()
->orderBy(id)
->fetchPairs();
$repos[''] = '';
return $repos;
}
/**
* list repos for sync
*