diff --git a/db/update12.0.1.sql b/db/update12.0.1.sql index c45645a1f5..1833845390 100644 --- a/db/update12.0.1.sql +++ b/db/update12.0.1.sql @@ -70,3 +70,7 @@ DROP `tagKeywords`, DROP `commentKeywords`, ADD `comment` varchar(255) COLLATE 'utf8_general_ci' NULL AFTER `atTime`, ADD `lastTag` varchar(255) COLLATE 'utf8_general_ci' NULL; + +ALTER TABLE `zt_compile` +CHANGE `cijob` `integration` mediumint(8) unsigned NOT NULL AFTER `name`, +CHANGE `queueItem` `queue` mediumint(8) NOT NULL AFTER `integration`; diff --git a/module/ci/model.php b/module/ci/model.php index d6c0623e10..920596fd60 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -33,7 +33,7 @@ class ciModel extends model { $compiles = $this->dao->select('t1.*, t2.jkJob, t3.name jenkinsName,t3.serviceUrl,t3.account,t3.token,t3.password') ->from(TABLE_COMPILE)->alias('t1') - ->leftJoin(TABLE_INTEGRATION)->alias('t2')->on('t1.cijob=t2.id') + ->leftJoin(TABLE_INTEGRATION)->alias('t2')->on('t1.integration=t2.id') ->leftJoin(TABLE_JENKINS)->alias('t3')->on('t2.jkHost=t3.id') ->where('t1.status')->ne('success') ->andWhere('t1.status')->ne('fail') @@ -49,19 +49,19 @@ class ciModel extends model $jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@'; $jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer); - $queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queueItem); + $queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queue); $response = common::http($queueUrl); if(strripos($response, "404") > -1) { /* Queue expired, use another api. */ - $infoUrl = sprintf('%s/job/%s/%s/api/json', $jenkinsServer, $compile->jkJob, $compile->queueItem); + $infoUrl = sprintf('%s/job/%s/%s/api/json', $jenkinsServer, $compile->jkJob, $compile->queue); $response = common::http($infoUrl); $buildInfo = json_decode($response); $result = strtolower($buildInfo->result); $this->updateBuildStatus($compile, $result); - $logUrl = sprintf('%s/job/%s/%s/consoleText', $jenkinsServer, $compile->jkJob, $compile->queueItem); + $logUrl = sprintf('%s/job/%s/%s/consoleText', $jenkinsServer, $compile->jkJob, $compile->queue); $response = common::http($logUrl); $logs = json_decode($response); @@ -111,7 +111,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->cijob)->exec(); + $this->dao->update(TABLE_INTEGRATION)->set('lastExec')->eq(helper::now())->set('lastStatus')->eq($status)->where('id')->eq($build->integration)->exec(); } /** diff --git a/module/compile/control.php b/module/compile/control.php index 7aac9b51be..508d0a46d4 100644 --- a/module/compile/control.php +++ b/module/compile/control.php @@ -28,6 +28,7 @@ class compile extends control /** * Browse jenkins build. * + * @param int $integrationID * @param string $orderBy * @param int $recTotal * @param int $recPerPage @@ -35,7 +36,7 @@ class compile extends control * @access public * @return void */ - public function browse($jobID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($integrationID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); @@ -45,10 +46,10 @@ class compile extends control $this->view->position[] = $this->lang->compile->browse; $this->app->loadLang('integration'); - $this->view->buildList = $this->compile->getList($jobID, $orderBy, $pager); - $this->view->jobID = $jobID; - $this->view->orderBy = $orderBy; - $this->view->pager = $pager; + $this->view->integrationID = $integrationID; + $this->view->buildList = $this->compile->getList($integrationID, $orderBy, $pager); + $this->view->orderBy = $orderBy; + $this->view->pager = $pager; $this->display(); } @@ -67,7 +68,7 @@ class compile extends control $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[] = html::a($this->createLink('compile', 'browse', "integrationID=" . $build->integration), $this->lang->compile->browse); $this->view->position[] = $this->lang->compile->logs; $this->display(); } diff --git a/module/compile/model.php b/module/compile/model.php index cec8606369..e2f85b96f3 100644 --- a/module/compile/model.php +++ b/module/compile/model.php @@ -14,21 +14,21 @@ class compileModel extends model /** * Get build list. * - * @param int $jobID + * @param int $integrationID * @param string $orderBy * @param object $pager * @access public * @return array */ - public function getList($jobID, $orderBy = 'id_desc', $pager = null) + public function getList($integrationID, $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_INTEGRATION)->alias('t2')->on('t1.integration=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.cijob')->ne('0') - ->beginIF(!empty($jobID))->andWhere('t1.cijob')->eq($jobID)->fi() + ->andWhere('t1.integration')->ne('0') + ->beginIF(!empty($integrationID))->andWhere('t1.integration')->eq($integrationID)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); @@ -58,9 +58,9 @@ class compileModel extends model } /** - * Save build by job + * Save build by integration * - * @param object $job + * @param int $integrationID * @access public * @return void */ @@ -69,7 +69,7 @@ class compileModel extends model $integration = $this->dao->select('id,name')->from(TABLE_INTEGRATION)->where('id')->eq($integrationID)->fetch(); $build = new stdClass(); - $build->cijob = $integration->id; + $build->integration = $integration->id; $build->name = $integration->name; $build->createdBy = $this->app->user->account; $build->createdDate = helper::now(); @@ -86,18 +86,18 @@ class compileModel extends model */ public function execByCompile($compile, $data = null) { - $integration = $this->dao->select('t1.id as jobId,t1.name as jobName,t1.repo,t1.jkJob,t2.name as jenkinsName,t2.serviceUrl,t2.account,t2.token,t2.password') + $integration = $this->dao->select('t1.id,t1.name,t1.repo,t1.jkJob,t2.name as jenkinsName,t2.serviceUrl,t2.account,t2.token,t2.password') ->from(TABLE_INTEGRATION)->alias('t1') ->leftJoin(TABLE_JENKINS)->alias('t2')->on('t1.jkHost=t2.id') - ->where('t1.id')->eq($compile->cijob) + ->where('t1.id')->eq($compile->integration) ->fetch(); if(!$integration) return false; $buildUrl = $this->getBuildUrl($integration); $build = new stdclass(); - $build->queueItem = $this->loadModel('ci')->sendRequest($buildUrl, $data); - $build->status = $build->queueItem ? 'created' : 'create_fail'; + $build->queue = $this->loadModel('ci')->sendRequest($buildUrl, $data); + $build->status = $build->queue ? 'created' : 'create_fail'; $this->dao->update(TABLE_COMPILE)->data($build)->where('id')->eq($compile->id)->exec(); return !dao::isError(); @@ -112,7 +112,7 @@ class compileModel extends model */ public function execByIntegration($integrationID, $data = null) { - $integration = $this->dao->select('t1.id as jobId,t1.name as jobName,t1.repo,t1.jkJob,t2.name as jenkinsName,t2.serviceUrl,t2.account,t2.token,t2.password') + $integration = $this->dao->select('t1.id,t1.name,t1.repo,t1.jkJob,t2.name as jenkinsName,t2.serviceUrl,t2.account,t2.token,t2.password') ->from(TABLE_INTEGRATION)->alias('t1') ->leftJoin(TABLE_JENKINS)->alias('t2')->on('t1.jkHost=t2.id') ->where('t1.id')->eq($integrationID) @@ -122,10 +122,10 @@ class compileModel extends model $buildUrl = $this->getBuildUrl($integration); $build = new stdClass(); - $build->cijob = $integration->jobId; - $build->name = $integration->jobName; - $build->queueItem = $this->loadModel('ci')->sendRequest($buildUrl, $data); - $build->status = $build->queueItem ? 'created' : 'create_fail'; + $build->integration = $integration->id; + $build->name = $integration->name; + $build->queue = $this->loadModel('ci')->sendRequest($buildUrl, $data); + $build->status = $build->queue ? 'created' : 'create_fail'; $build->createdBy = $this->app->user->account; $build->createdDate = helper::now(); $this->dao->insert(TABLE_COMPILE)->data($build)->exec(); diff --git a/module/compile/view/browse.html.php b/module/compile/view/browse.html.php index 13b2af57ad..42b7b9f4b9 100644 --- a/module/compile/view/browse.html.php +++ b/module/compile/view/browse.html.php @@ -25,7 +25,7 @@
| compile->id);?> | compile->name);?> | integration->repo;?> | diff --git a/module/compile/view/logs.html.php b/module/compile/view/logs.html.php index 7a0e262e81..0f401e9984 100644 --- a/module/compile/view/logs.html.php +++ b/module/compile/view/logs.html.php @@ -18,7 +18,7 @@lastStatus) echo zget($lang->compile->statusList, $job->lastStatus) . $lang->ci->at . $job->lastExec;?> | createLink('integration', 'delete', "jobID=$id"), '', 'hiddenwin', "title='{$lang->integration->delete}' class='btn'"); + common::printIcon('compile', 'browse', "integrationID=$id", '', 'list', 'file-text'); + common::printIcon('integration', 'edit', "integrationID=$id", '', 'list', 'edit'); + if(common::hasPriv('integration', 'delete')) echo html::a($this->createLink('integration', 'delete', "integrationID=$id"), '', 'hiddenwin', "title='{$lang->integration->delete}' class='btn'"); ?> |
|---|