# Conflicts:
#	config/zentaopms.php
#	module/gitlab/model.php
This commit is contained in:
David.li
2021-06-08 13:34:19 +08:00
14 changed files with 56 additions and 133 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ define('TABLE_LOG', '`' . $config->db->prefix . 'log`');
define('TABLE_SCORE', '`' . $config->db->prefix . 'score`');
define('TABLE_NOTIFY', '`' . $config->db->prefix . 'notify`');
define('TABLE_OAUTH', '`' . $config->db->prefix . 'oauth`');
define('TABLE_PIPLINE', '`' . $config->db->prefix . 'pipline`');
define('TABLE_PIPELINE', '`' . $config->db->prefix . 'pipeline`');
define('TABLE_JOB', '`' . $config->db->prefix . 'job`');
define('TABLE_COMPILE', '`' . $config->db->prefix . 'compile`');
+3 -2
View File
@@ -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,
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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')
+2 -2
View File
@@ -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();
+6 -45
View File
@@ -21,10 +21,7 @@ class gitlabModel extends model
*/
public function getByID($id)
{
$gitlab = $this->dao->select('*')->from(TABLE_PIPLINE)->where('id')->eq($id)->fetch();
$gitlab->password = base64_decode($gitlab->password);
return $gitlab;
return $this->loadModel('pipeline')->getByID($id);
}
/**
@@ -37,12 +34,7 @@ class gitlabModel extends model
*/
public function getList($orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('*')->from(TABLE_PIPLINE)
->where('deleted')->eq('0')
->andwhere('type')->eq('1')
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
return $this->loadModel('pipeline')->getList('gitlab', $orderBy, $pager);
}
/**
@@ -52,11 +44,7 @@ class gitlabModel extends model
*/
public function getPairs()
{
$gitlab = $this->dao->select('id,name')->from(TABLE_PIPLINE)
->where('deleted')->eq('0')
->orderBy('id')->fetchPairs('id', 'name');
$gitlab = array('' => '') + $gitlab;
return $gitlab;
return $this->loadModel('pipeline')->getPairs('gitlab');
}
/**
@@ -67,20 +55,7 @@ class gitlabModel extends model
*/
public function create()
{
$gitlab = fixer::input('post')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->add('type', 1)
->skipSpecial('url,token')
->get();
$this->dao->insert(TABLE_PIPLINE)->data($gitlab)
->batchCheck($this->config->gitlab->create->requiredFields, 'notempty')
->autoCheck()
->exec();
if(dao::isError()) return false;
return $this->dao->lastInsertId();
return $this->loadModel('pipeline')->create('gitlab');
}
/**
@@ -92,19 +67,7 @@ class gitlabModel extends model
*/
public function update($id)
{
$gitlab = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::now())
->skipSpecial('url,token')
->get();
$this->dao->update(TABLE_PIPLINE)->data($gitlab)
->batchCheck($this->config->gitlab->edit->requiredFields, 'notempty')
->batchCheck("url", 'URL')
->autoCheck()
->where('id')->eq($id)
->exec();
return !dao::isError();
return $this->loadModel('pipeline')->update($id);
}
/**
@@ -118,11 +81,9 @@ class gitlabModel extends model
public function getPermissionsByToken($host, $token)
{
$host = rtrim($host, '/');
$host .= '/api/v4/user/activities';
$host .= '/api/v4/activities';
$results = json_decode(file_get_contents($host . "?private_token=$token"));
return $results;
}
}
+1 -1
View File
@@ -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'));
}
+5 -44
View File
@@ -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('pipeline')->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('pipeline')->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('pipeline')->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('pipeline')->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('pipeline')->update($id);
}
}
+2 -2
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
<?php
$config->pipeline->create = new stdclass();
$config->pipeline->edit = new stdclass();
$config->pipeline->create->requiredFields = 'name,url,type';
$config->pipeline->edit->requiredFields = 'name,url,type';
+7
View File
@@ -0,0 +1,7 @@
<?php
$lang->pipeline->id = 'ID';
$lang->pipeline->name = '名称';
$lang->pipeline->url = '服务地址';
$lang->pipeline->token = 'Token';
$lang->pipeline->account = '用户名';
$lang->pipeline->password = '密码';
@@ -1,6 +1,6 @@
<?php
/**
* The model file of pipline module of ZenTaoPMS.
* The model file of pipeline 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)
@@ -10,10 +10,10 @@
* @link http://www.zentao.net
*/
class piplineModel extends model
class pipelineModel extends model
{
/**
* Get a pipline by id.
* Get a pipeline by id.
*
* @param int $id
* @access public
@@ -21,13 +21,13 @@ class piplineModel extends model
*/
public function getByID($id)
{
$pipline = $this->dao->select('*')->from(TABLE_PIPLINE)->where('id')->eq($id)->fetch();
$pipline->password = base64_decode($pipline->password);
return $pipline;
$pipeline = $this->dao->select('*')->from(TABLE_PIPELINE)->where('id')->eq($id)->fetch();
$pipeline->password = base64_decode($pipeline->password);
return $pipeline;
}
/**
* Get pipline list.
* Get pipeline list.
*
* @param string $type jenkins|gitlab
* @param string $orderBy
@@ -37,7 +37,7 @@ class piplineModel extends model
*/
public function getList($type = 'jenkins', $orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('*')->from(TABLE_PIPLINE)
return $this->dao->select('*')->from(TABLE_PIPELINE)
->where('deleted')->eq('0')
->AndWhere('type')->eq($type)
->orderBy($orderBy)
@@ -46,39 +46,39 @@ class piplineModel extends model
}
/**
* Get pipline pairs
* Get pipeline pairs
*
* @return array
*/
public function getPairs($type)
{
$pipline = $this->dao->select('id,name')->from(TABLE_PIPLINE)
$pipeline = $this->dao->select('id,name')->from(TABLE_PIPELINE)
->where('deleted')->eq('0')
->AndWhere('type')->eq($type)
->orderBy('id')->fetchPairs('id', 'name');
$pipline = array('' => '') + $pipline;
return $pipline;
$pipeline = array('' => '') + $pipeline;
return $pipeline;
}
/**
* Create a pipline.
* Create a pipeline.
*
* @access public
* @return bool
*/
public function create($type)
{
$pipline = fixer::input('post')
$pipeline = fixer::input('post')
->add('type', $type)
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->skipSpecial('url,token,account,password')
->get();
$pipline->password = base64_encode($pipline->password);
$pipeline->password = base64_encode($pipeline->password);
$this->dao->insert(TABLE_PIPLINE)->data($pipline)
->batchCheck($this->config->pipline->create->requiredFields, 'notempty')
$this->dao->insert(TABLE_PIPELINE)->data($pipeline)
->batchCheck($this->config->pipeline->create->requiredFields, 'notempty')
->batchCheck("url", 'URL')
->autoCheck()
->exec();
@@ -87,7 +87,7 @@ class piplineModel extends model
}
/**
* Update a pipline.
* Update a pipeline.
*
* @param int $id
* @access public
@@ -95,16 +95,16 @@ class piplineModel extends model
*/
public function update($id)
{
$pipline = fixer::input('post')
$pipeline = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::now())
->skipSpecial('url,token,account,password')
->get();
$pipline->password = base64_encode($pipline->password);
$pipeline->password = base64_encode($pipeline->password);
$this->dao->update(TABLE_PIPLINE)->data($pipline)
->batchCheck($this->config->pipline->edit->requiredFields, 'notempty')
$this->dao->update(TABLE_PIPELINE)->data($pipeline)
->batchCheck($this->config->pipeline->edit->requiredFields, 'notempty')
->batchCheck("url", 'URL')
->autoCheck()
->where('id')->eq($id)
-5
View File
@@ -1,5 +0,0 @@
<?php
$config->pipline->create = new stdclass();
$config->pipline->edit = new stdclass();
$config->pipline->create->requiredFields = 'name,url,type';
$config->pipline->edit->requiredFields = 'name,url,type';
-7
View File
@@ -1,7 +0,0 @@
<?php
$lang->pipline->id = 'ID';
$lang->pipline->name = '名称';
$lang->pipline->url = '服务地址';
$lang->pipline->token = 'Token';
$lang->pipline->account = '用户名';
$lang->pipline->password = '密码';