diff --git a/db/zentao.sql b/db/zentao.sql index fa9301cc1e..adcd1b45d3 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -471,9 +471,10 @@ CREATE TABLE IF NOT EXISTS `zt_history` ( PRIMARY KEY (`id`), KEY `action` (`action`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- DROP TABLE IF EXISTS `zt_jenkins`; -CREATE TABLE IF NOT EXISTS `zt_jenkins` ( +-- DROP TABLE IF EXISTS `zt_pipline`; +CREATE TABLE IF NOT EXISTS `zt_pipline` ( `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT, + `type` char(30) NOT NULL, `name` varchar(50) NOT NULL, `url` varchar(255) DEFAULT NULL, `account` varchar(30) DEFAULT NULL, diff --git a/module/ci/control.php b/module/ci/control.php index b22366f61e..654a48a2a1 100644 --- a/module/ci/control.php +++ b/module/ci/control.php @@ -104,7 +104,7 @@ class ci extends control { $compile = $this->dao->select('t1.*, t2.jkJob,t2.product,t2.frame,t3.name as jenkinsName,t3.url,t3.account,t3.token,t3.password')->from(TABLE_COMPILE)->alias('t1') ->leftJoin(TABLE_JOB)->alias('t2')->on('t1.job=t2.id') - ->leftJoin(TABLE_JENKINS)->alias('t3')->on('t2.jkHost=t3.id') + ->leftJoin(TABLE_PIPELINE)->alias('t3')->on('t2.jkHost=t3.id') ->where('t1.id')->eq($compileID) ->fetch(); diff --git a/module/ci/model.php b/module/ci/model.php index 46ff711cc9..3a0093d85e 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -31,7 +31,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_JOB)->alias('t2')->on('t1.job=t2.id') - ->leftJoin(TABLE_JENKINS)->alias('t3')->on('t2.jkHost=t3.id') + ->leftJoin(TABLE_PIPELINE)->alias('t3')->on('t2.jkHost=t3.id') ->where('t1.status')->ne('success') ->andWhere('t1.status')->ne('failure') ->andWhere('t1.status')->ne('create_fail') diff --git a/module/compile/model.php b/module/compile/model.php index 7f82a344ce..f9f1646335 100644 --- a/module/compile/model.php +++ b/module/compile/model.php @@ -37,7 +37,7 @@ class compileModel extends model return $this->dao->select('t1.id, t1.name, t1.job, t1.status, t1.createdDate,t1.testtask, 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_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') + ->leftJoin(TABLE_PIPELINE)->alias('t4')->on('t2.jkHost=t4.id') ->where('t1.deleted')->eq('0') ->andWhere('t1.job')->ne('0') ->beginIF(!empty($jobID))->andWhere('t1.job')->eq($jobID)->fi() @@ -123,7 +123,7 @@ class compileModel extends model { $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') + ->leftJoin(TABLE_PIPELINE)->alias('t2')->on('t1.jkHost=t2.id') ->where('t1.id')->eq($compile->job) ->fetch(); diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 51d296384a..9ede8dfaa1 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -21,7 +21,7 @@ class gitlabModel extends model */ public function getByID($id) { - $gitlab = $this->dao->select('*')->from(TABLE_JENKINS)->where('id')->eq($id)->fetch(); + $gitlab = $this->dao->select('*')->from(TABLE_PIPELINE)->where('id')->eq($id)->fetch(); $gitlab->password = base64_decode($gitlab->password); return $gitlab; @@ -37,7 +37,7 @@ class gitlabModel extends model */ public function getList($orderBy = 'id_desc', $pager = null) { - return $this->dao->select('*')->from(TABLE_JENKINS) + return $this->dao->select('*')->from(TABLE_PIPELINE) ->where('deleted')->eq('0') ->andwhere('type')->eq('1') ->orderBy($orderBy) @@ -52,7 +52,7 @@ class gitlabModel extends model */ public function getPairs() { - $gitlab = $this->dao->select('id,name')->from(TABLE_JENKINS) + $gitlab = $this->dao->select('id,name')->from(TABLE_PIPELINE) ->where('deleted')->eq('0') ->orderBy('id')->fetchPairs('id', 'name'); $gitlab = array('' => '') + $gitlab; @@ -74,7 +74,7 @@ class gitlabModel extends model ->skipSpecial('url,token') ->get(); - $this->dao->insert(TABLE_JENKINS)->data($gitlab) + $this->dao->insert(TABLE_PIPELINE)->data($gitlab) ->batchCheck($this->config->gitlab->create->requiredFields, 'notempty') ->batchCheck("url", 'URL') ->autoCheck() @@ -98,7 +98,7 @@ class gitlabModel extends model ->skipSpecial('url,token') ->get(); - $this->dao->update(TABLE_JENKINS)->data($gitlab) + $this->dao->update(TABLE_PIPELINE)->data($gitlab) ->batchCheck($this->config->gitlab->edit->requiredFields, 'notempty') ->batchCheck("url", 'URL') ->autoCheck() diff --git a/module/jenkins/control.php b/module/jenkins/control.php index 70c030d2a4..1a77a02d27 100644 --- a/module/jenkins/control.php +++ b/module/jenkins/control.php @@ -111,7 +111,7 @@ class jenkins extends control { if($confim != 'yes') die(js::confirm($this->lang->jenkins->confirmDelete, inlink('delete', "id=$id&confirm=yes"))); - $this->jenkins->delete(TABLE_JENKINS, $id); + $this->jenkins->delete(TABLE_PIPELINE, $id); die(js::reload('parent')); } diff --git a/module/jenkins/model.php b/module/jenkins/model.php index 2d12469a3f..2c7eab673a 100644 --- a/module/jenkins/model.php +++ b/module/jenkins/model.php @@ -21,10 +21,7 @@ class jenkinsModel extends model */ public function getByID($id) { - $jenkins = $this->dao->select('*')->from(TABLE_JENKINS)->where('id')->eq($id)->fetch(); - $jenkins->password = base64_decode($jenkins->password); - - return $jenkins; + return $this->loadModel('pipline')->getByID($id); } /** @@ -37,11 +34,7 @@ class jenkinsModel extends model */ public function getList($orderBy = 'id_desc', $pager = null) { - return $this->dao->select('*')->from(TABLE_JENKINS) - ->where('deleted')->eq('0') - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('id'); + return $this->loadModel('pipline')->getList('jenkins', $orderBy, $pager); } /** @@ -51,11 +44,7 @@ class jenkinsModel extends model */ public function getPairs() { - $jenkins = $this->dao->select('id,name')->from(TABLE_JENKINS) - ->where('deleted')->eq('0') - ->orderBy('id')->fetchPairs('id', 'name'); - $jenkins = array('' => '') + $jenkins; - return $jenkins; + return $this->loadModel('pipline')->getPairs('jenkins'); } /** @@ -94,21 +83,7 @@ class jenkinsModel extends model */ public function create() { - $jenkins = fixer::input('post') - ->add('createdBy', $this->app->user->account) - ->add('createdDate', helper::now()) - ->skipSpecial('url,token,account,password') - ->get(); - - $jenkins->password = base64_encode($jenkins->password); - - $this->dao->insert(TABLE_JENKINS)->data($jenkins) - ->batchCheck($this->config->jenkins->create->requiredFields, 'notempty') - ->batchCheck("url", 'URL') - ->autoCheck() - ->exec(); - if(dao::isError()) return false; - return $this->dao->lastInsertId(); + return $this->loadModel('pipline')->create('jenkins'); } /** @@ -120,20 +95,6 @@ class jenkinsModel extends model */ public function update($id) { - $jenkins = fixer::input('post') - ->add('editedBy', $this->app->user->account) - ->add('editedDate', helper::now()) - ->skipSpecial('url,token,account,password') - ->get(); - - $jenkins->password = base64_encode($jenkins->password); - - $this->dao->update(TABLE_JENKINS)->data($jenkins) - ->batchCheck($this->config->jenkins->edit->requiredFields, 'notempty') - ->batchCheck("url", 'URL') - ->autoCheck() - ->where('id')->eq($id) - ->exec(); - return !dao::isError(); + return $this->loadModel('pipline')->update($id); } } diff --git a/module/job/model.php b/module/job/model.php index 5d19e6c298..c948ada4e7 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -35,7 +35,7 @@ class jobModel extends model { 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') + ->leftJoin(TABLE_PIPELINE)->alias('t3')->on('t1.jkHost=t3.id') ->where('t1.deleted')->eq('0') ->orderBy($orderBy) ->page($pager) @@ -290,7 +290,7 @@ class jobModel extends model { $job = $this->dao->select('t1.id,t1.name,t1.product,t1.repo,t1.jkJob,t1.triggerType,t1.atTime,t1.customParam,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') + ->leftJoin(TABLE_PIPELINE)->alias('t2')->on('t1.jkHost=t2.id') ->where('t1.id')->eq($id) ->fetch(); if(!$job) return false;