Merge branch 'master' into 'sprint/183_mayue_47996'
# Conflicts: # db/update16.2.sql
This commit is contained in:
@@ -292,6 +292,9 @@ $config->objectTables['kanbanlane'] = TABLE_KANBANLANE;
|
||||
$config->objectTables['kanbanorder'] = TABLE_KANBANORDER;
|
||||
$config->objectTables['kanbangroup'] = TABLE_KANBANGROUP;
|
||||
$config->objectTables['kanbancard'] = TABLE_KANBANCARD;
|
||||
$config->objectTables['sonarqube'] = TABLE_PIPELINE;
|
||||
$config->objectTables['gitlab'] = TABLE_PIPELINE;
|
||||
$config->objectTables['jebkins'] = TABLE_PIPELINE;
|
||||
|
||||
$config->newFeatures = array('introduction', 'tutorial', 'youngBlueTheme');
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
ALTER TABLE `zt_kanbanspace` ADD `type` varchar(50) NOT NULL AFTER `name`;
|
||||
UPDATE `zt_kanbanspace` SET `type` = 'cooperation';
|
||||
ALTER TABLE `zt_kanban` ADD `performable` enum ('0', '1') NOT NULL DEFAULT '0' AFTER `archived`;
|
||||
|
||||
ALTER TABLE `zt_job` ADD `sonarqubeServer` mediumint(8) unsigned NOT NULL AFTER `triggerType`;
|
||||
ALTER TABLE `zt_job` ADD `projectKey` varchar(255) NOT NULL AFTER `sonarqubeServer`;
|
||||
@@ -40,6 +40,7 @@ $config->action->objectNameFields['kanbanspace'] = 'name';
|
||||
$config->action->objectNameFields['kanbanregion'] = 'name';
|
||||
$config->action->objectNameFields['kanban'] = 'name';
|
||||
$config->action->objectNameFields['kanbancard'] = 'name';
|
||||
$config->action->objectNameFields['sonarqube'] = 'name';
|
||||
|
||||
$config->action->commonImgSize = 870;
|
||||
|
||||
@@ -55,4 +56,4 @@ $config->action->majorList['execution'] = array('opened', 'edited');
|
||||
|
||||
$config->action->needGetProjectType = 'build,task,bug,case,testcase,caselib,testtask,testsuite,testreport,doc,issue,release,risk,design,opportunity,trainplan,gapanalysis,researchplan,researchreport,';
|
||||
$config->action->needGetRelateField = ',story,productplan,release,task,build,bug,case,testtask,testreport,doc,doclib,issue,risk,opportunity,trainplan,gapanalysis,team,whitelist,researchplan,researchreport,meeting,kanbanlane,kanbancolumn,';
|
||||
$config->action->noLinkModules = ',doclib,module,webhook,gitlab,pipeline,jenkins,kanban,kanbanspace,kanbancolumn,kanbanlane,kanbanregion,kanbancard,execution,project,';
|
||||
$config->action->noLinkModules = ',doclib,module,webhook,gitlab,sonarqube,pipeline,jenkins,kanban,kanbanspace,kanbancolumn,kanbanlane,kanbanregion,kanbancard,execution,project,';
|
||||
|
||||
@@ -134,6 +134,8 @@ $lang->action->objectTypes['kanbanregion'] = 'Kanban Region';
|
||||
$lang->action->objectTypes['kanbanlane'] = 'Kanban Lane';
|
||||
$lang->action->objectTypes['kanbancolumn'] = 'Kanban Column';
|
||||
$lang->action->objectTypes['kanbancard'] = 'Kanban Card';
|
||||
$lang->action->objectTypes['sonarqube'] = 'SonarQube Server';
|
||||
$lang->action->objectTypes['sonarqubeproject'] = 'SonarQube Project';
|
||||
|
||||
/* Used to describe operation history. */
|
||||
$lang->action->desc = new stdclass();
|
||||
@@ -329,6 +331,7 @@ $lang->action->label->finishedbychild = 'finished';
|
||||
$lang->action->label->closedbychild = 'closed';
|
||||
$lang->action->label->activatedbychild = 'activated';
|
||||
$lang->action->label->createchild = 'activated';
|
||||
$lang->action->label->executed = 'executed';
|
||||
|
||||
/* Dynamic information is grouped by object. */
|
||||
$lang->action->dynamicAction = new stdclass;
|
||||
@@ -568,6 +571,22 @@ $lang->action->dynamicAction->user['loginxuanxuan'] = 'Login Desktop';
|
||||
$lang->action->dynamicAction->entry['created'] = 'Add Application';
|
||||
$lang->action->dynamicAction->entry['edited'] = 'Edit Application';
|
||||
|
||||
$lang->action->dynamicAction->job['created'] = 'Create Job';
|
||||
$lang->action->dynamicAction->job['edited'] = 'Edit Job';
|
||||
$lang->action->dynamicAction->job['executed'] = 'Execute Job';
|
||||
$lang->action->dynamicAction->job['deleted'] = 'Delete Job';
|
||||
$lang->action->dynamicAction->job['undeleted'] = 'Undelete Job';
|
||||
|
||||
$lang->action->dynamicAction->sonarqube['created'] = 'Create SonarQube Server';
|
||||
$lang->action->dynamicAction->sonarqube['edited'] = 'Edit SonarQube Server';
|
||||
$lang->action->dynamicAction->sonarqube['deleted'] = 'Delete SonarQube Server';
|
||||
|
||||
$lang->action->dynamicAction->sonarqubeproject['deleted'] = 'Delete SonarQube Project';
|
||||
|
||||
$lang->action->dynamicAction->gitlab['created'] = 'Create GitLab Server';
|
||||
$lang->action->dynamicAction->gitlab['edited'] = 'Edit GitLab Server';
|
||||
$lang->action->dynamicAction->gitlab['deleted'] = 'Delete GitLab Server';
|
||||
|
||||
/* Generate the corresponding object link. */
|
||||
$lang->action->label->product = $lang->productCommon . '|product|view|productID=%s';
|
||||
$lang->action->label->productplan = 'Plan|productplan|view|productID=%s';
|
||||
|
||||
@@ -134,6 +134,8 @@ $lang->action->objectTypes['kanbanregion'] = '看板区域';
|
||||
$lang->action->objectTypes['kanbanlane'] = '看板泳道';
|
||||
$lang->action->objectTypes['kanbancolumn'] = '看板列';
|
||||
$lang->action->objectTypes['kanbancard'] = '看板卡片';
|
||||
$lang->action->objectTypes['sonarqube'] = 'SonarQube服务器';
|
||||
$lang->action->objectTypes['sonarqubeproject'] = 'SonarQube项目';
|
||||
|
||||
/* 用来描述操作历史记录。*/
|
||||
$lang->action->desc = new stdclass();
|
||||
@@ -329,6 +331,7 @@ $lang->action->label->finishedbychild = '完成了';
|
||||
$lang->action->label->closedbychild = '关闭了';
|
||||
$lang->action->label->activatedbychild = '激活了';
|
||||
$lang->action->label->createchild = '激活了';
|
||||
$lang->action->label->executed = '执行了';
|
||||
|
||||
/* 动态信息按照对象分组 */
|
||||
$lang->action->dynamicAction = new stdclass();
|
||||
@@ -568,6 +571,22 @@ $lang->action->dynamicAction->user['loginxuanxuan'] = '登录客户端';
|
||||
$lang->action->dynamicAction->entry['created'] = '添加应用';
|
||||
$lang->action->dynamicAction->entry['edited'] = '编辑应用';
|
||||
|
||||
$lang->action->dynamicAction->job['created'] = '创建构建任务';
|
||||
$lang->action->dynamicAction->job['edited'] = '编辑构建任务';
|
||||
$lang->action->dynamicAction->job['executed'] = '执行构建任务';
|
||||
$lang->action->dynamicAction->job['deleted'] = '删除构建任务';
|
||||
$lang->action->dynamicAction->job['undeleted'] = '还原构建任务';
|
||||
|
||||
$lang->action->dynamicAction->sonarqube['created'] = '创建SonarQube服务器';
|
||||
$lang->action->dynamicAction->sonarqube['edited'] = '设置SonarQube服务器';
|
||||
$lang->action->dynamicAction->sonarqube['deleted'] = '删除SonarQube服务器';
|
||||
|
||||
$lang->action->dynamicAction->sonarqubeproject['deleted'] = '删除SonarQube项目';
|
||||
|
||||
$lang->action->dynamicAction->gitlab['created'] = '创建GitLab服务器';
|
||||
$lang->action->dynamicAction->gitlab['edited'] = '设置GitLab服务器';
|
||||
$lang->action->dynamicAction->gitlab['deleted'] = '删除GitLab服务器';
|
||||
|
||||
/* 用来生成相应对象的链接。*/
|
||||
$lang->action->label->product = $lang->productCommon . '|product|view|productID=%s';
|
||||
$lang->action->label->productplan = "计划|productplan|view|productID=%s";
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
{
|
||||
$user = zget($users, $action->actor);
|
||||
if($action->action == 'login' or $action->action == 'logout') $action->objectName = $action->objectLabel = '';
|
||||
if($action->objectType == 'sonarqubeproject') $action->objectName = $action->extra;
|
||||
$class = $action->major ? "class='active'" : '';
|
||||
echo "<li $class><div>";
|
||||
if($action->objectLink) printf($lang->block->dynamicInfo, $action->date, $user, $action->actionLabel, $action->objectLabel, $action->objectLink, $action->objectName, $action->objectName);
|
||||
|
||||
+25
-21
@@ -386,22 +386,24 @@ $lang->qa->menuOrder[45] = 'automation';
|
||||
$lang->qa->dividerMenu = ',bug,testtask,caselib,';
|
||||
|
||||
/* DevOps menu. */
|
||||
$lang->devops->menu = new stdclass();
|
||||
$lang->devops->menu->code = array('link' => "{$lang->repo->common}|repo|browse|repoID=%s", 'alias' => 'diff,view,revision,log,blame,showsynccommit');
|
||||
$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job');
|
||||
$lang->devops->menu->mr = array('link' => "{$lang->devops->mr}|mr|browse");
|
||||
$lang->devops->menu->gitlab = array('link' => "GitLab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->jenkins = array('link' => "Jenkins|jenkins|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->maintain = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->rules = array('link' => "{$lang->devops->rules}|repo|setrules");
|
||||
$lang->devops->menu = new stdclass();
|
||||
$lang->devops->menu->code = array('link' => "{$lang->repo->common}|repo|browse|repoID=%s", 'alias' => 'diff,view,revision,log,blame,showsynccommit');
|
||||
$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job');
|
||||
$lang->devops->menu->mr = array('link' => "{$lang->devops->mr}|mr|browse");
|
||||
$lang->devops->menu->gitlab = array('link' => "GitLab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->sonarqube = array('link' => "SonarQube|sonarqube|browse");
|
||||
$lang->devops->menu->jenkins = array('link' => "Jenkins|jenkins|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->maintain = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->rules = array('link' => "{$lang->devops->rules}|repo|setrules");
|
||||
|
||||
$lang->devops->menuOrder[5] = 'code';
|
||||
$lang->devops->menuOrder[10] = 'compile';
|
||||
$lang->devops->menuOrder[15] = 'mr';
|
||||
$lang->devops->menuOrder[20] = 'gitlab';
|
||||
$lang->devops->menuOrder[25] = 'jenkins';
|
||||
$lang->devops->menuOrder[30] = 'maintain';
|
||||
$lang->devops->menuOrder[35] = 'rules';
|
||||
$lang->devops->menuOrder[25] = 'sonarqube';
|
||||
$lang->devops->menuOrder[30] = 'jenkins';
|
||||
$lang->devops->menuOrder[35] = 'maintain';
|
||||
$lang->devops->menuOrder[40] = 'rules';
|
||||
|
||||
/* Kanban menu. */
|
||||
$lang->kanban->menu = new stdclass();
|
||||
@@ -618,16 +620,18 @@ $lang->navGroup->testtask = 'qa';
|
||||
$lang->navGroup->testsuite = 'qa';
|
||||
$lang->navGroup->caselib = 'qa';
|
||||
|
||||
$lang->navGroup->devops = 'devops';
|
||||
$lang->navGroup->repo = 'devops';
|
||||
$lang->navGroup->job = 'devops';
|
||||
$lang->navGroup->jenkins = 'devops';
|
||||
$lang->navGroup->mr = 'devops';
|
||||
$lang->navGroup->gitlab = 'devops';
|
||||
$lang->navGroup->compile = 'devops';
|
||||
$lang->navGroup->ci = 'devops';
|
||||
$lang->navGroup->svn = 'devops';
|
||||
$lang->navGroup->git = 'devops';
|
||||
$lang->navGroup->devops = 'devops';
|
||||
$lang->navGroup->repo = 'devops';
|
||||
$lang->navGroup->job = 'devops';
|
||||
$lang->navGroup->jenkins = 'devops';
|
||||
$lang->navGroup->mr = 'devops';
|
||||
$lang->navGroup->gitlab = 'devops';
|
||||
$lang->navGroup->sonarqube = 'devops';
|
||||
$lang->navGroup->sonarqubeproject = 'devops';
|
||||
$lang->navGroup->compile = 'devops';
|
||||
$lang->navGroup->ci = 'devops';
|
||||
$lang->navGroup->svn = 'devops';
|
||||
$lang->navGroup->git = 'devops';
|
||||
|
||||
$lang->navGroup->company = 'system';
|
||||
|
||||
|
||||
@@ -66,10 +66,14 @@
|
||||
<?php $tab = '';?>
|
||||
<?php if($action->objectType == 'meeting') $tab = $action->project ? "data-app='project'" : "data-app='my'";?>
|
||||
<?php
|
||||
if(empty($action->objectName))
|
||||
if(empty($action->objectName) and $action->objectID)
|
||||
{
|
||||
echo '#' . $action->objectID;
|
||||
}
|
||||
elseif(empty($action->objectID) and $action->extra)
|
||||
{
|
||||
echo $action->extra;
|
||||
}
|
||||
elseif(empty($action->objectLink))
|
||||
{
|
||||
echo $action->objectName;
|
||||
@@ -79,8 +83,10 @@
|
||||
echo html::a($action->objectLink, $action->objectName, '', $tab);
|
||||
}
|
||||
?>
|
||||
<?php if($action->objectID):?>
|
||||
<span class="label label-id"><?php echo $action->objectID;?></span>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<th class='c-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->gitlab->id);?></th>
|
||||
<th class='c-id text-center'><?php common::printOrderLink('id', $orderBy, $vars, $lang->gitlab->id);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->name);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('url', $orderBy, $vars, $lang->gitlab->url);?></th>
|
||||
<th class='c-actions-6'><?php echo $lang->actions;?></th>
|
||||
|
||||
@@ -1384,6 +1384,24 @@ $lang->gitlab->methodOrder[135] = 'browseTag';
|
||||
$lang->gitlab->methodOrder[140] = 'browseTagPriv';
|
||||
$lang->gitlab->methodOrder[145] = 'deleteTagPriv';
|
||||
|
||||
/* SonarQube. */
|
||||
$lang->resource->sonarqube = new stdclass();
|
||||
$lang->resource->sonarqube->browse = 'browse';
|
||||
$lang->resource->sonarqube->create = 'create';
|
||||
$lang->resource->sonarqube->edit = 'edit';
|
||||
$lang->resource->sonarqube->delete = 'delete';
|
||||
$lang->resource->sonarqube->browseProject = 'browseProject';
|
||||
$lang->resource->sonarqube->deleteProject = 'deleteProject';
|
||||
$lang->resource->sonarqube->execJob = 'execJob';
|
||||
|
||||
$lang->sonarqube->methodOrder[5] = 'browse';
|
||||
$lang->sonarqube->methodOrder[10] = 'create';
|
||||
$lang->sonarqube->methodOrder[15] = 'edit';
|
||||
$lang->sonarqube->methodOrder[20] = 'delete';
|
||||
$lang->sonarqube->methodOrder[25] = 'browseProject';
|
||||
$lang->sonarqube->methodOrder[35] = 'deleteProject';
|
||||
$lang->sonarqube->methodOrder[40] = 'execJob';
|
||||
|
||||
/* merge request. */
|
||||
$lang->resource->mr = new stdclass();
|
||||
$lang->resource->mr->create = 'create';
|
||||
@@ -1728,12 +1746,12 @@ $lang->backup->methodOrder[25] = 'setting';
|
||||
$lang->backup->methodOrder[30] = 'rmPHPHeader';
|
||||
|
||||
$lang->resource->cron = new stdclass();
|
||||
$lang->resource->cron->index = 'index';
|
||||
$lang->resource->cron->turnon = 'turnon';
|
||||
$lang->resource->cron->create = 'createAction';
|
||||
$lang->resource->cron->edit = 'edit';
|
||||
$lang->resource->cron->toggle = 'toggle';
|
||||
$lang->resource->cron->delete = 'delete';
|
||||
$lang->resource->cron->index = 'index';
|
||||
$lang->resource->cron->turnon = 'turnon';
|
||||
$lang->resource->cron->create = 'createAction';
|
||||
$lang->resource->cron->edit = 'edit';
|
||||
$lang->resource->cron->toggle = 'toggle';
|
||||
$lang->resource->cron->delete = 'delete';
|
||||
$lang->resource->cron->openProcess = 'restart';
|
||||
|
||||
$lang->cron->methodOrder[5] = 'index';
|
||||
|
||||
+36
-12
@@ -88,6 +88,8 @@ class job extends control
|
||||
}
|
||||
return $this->send(array('result' => 'fail', 'message' => $errors));
|
||||
}
|
||||
|
||||
$this->loadModel('action')->create('job', $jobID, 'created');
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $jobID));
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
@@ -120,7 +122,8 @@ class job extends control
|
||||
$this->view->repoTypes = $repoTypes;
|
||||
$this->view->products = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->projectID);
|
||||
|
||||
$this->view->jenkinsServerList = array('' => '') + $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->jenkinsServerList = array('' => '') + $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube');
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -162,6 +165,8 @@ class job extends control
|
||||
}
|
||||
return $this->send(array('result' => 'fail', 'message' => $errors));
|
||||
}
|
||||
|
||||
$this->loadModel('action')->create('job', $id, 'edited');
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
@@ -189,17 +194,18 @@ class job extends control
|
||||
if($jobProduct and $jobProduct->deleted == 0) $products += array($job->product => $jobProduct->name);
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->edit;
|
||||
$this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
|
||||
$this->view->position[] = $this->lang->job->edit;
|
||||
$this->view->repoPairs = $repoPairs;
|
||||
$this->view->gitlabRepos = $gitlabRepos;
|
||||
$this->view->repoTypes = $repoTypes;
|
||||
$this->view->repoType = zget($repoTypes, $job->repo, 'Git');
|
||||
$this->view->job = $job;
|
||||
$this->view->products = array(0 => '') + $products;
|
||||
$this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->pipelines = $this->jenkins->getTasks($job->server);
|
||||
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->edit;
|
||||
$this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job);
|
||||
$this->view->position[] = $this->lang->job->edit;
|
||||
$this->view->repoPairs = $repoPairs;
|
||||
$this->view->gitlabRepos = $gitlabRepos;
|
||||
$this->view->repoTypes = $repoTypes;
|
||||
$this->view->repoType = zget($repoTypes, $job->repo, 'Git');
|
||||
$this->view->job = $job;
|
||||
$this->view->products = array('') + $products;
|
||||
$this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube');
|
||||
$this->view->pipelines = $this->jenkins->getTasks($job->server);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -323,6 +329,7 @@ class job extends control
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->app->loadLang('compile');
|
||||
$this->loadModel('action')->create('job', $id, 'executed');
|
||||
return $this->send(array('result' => 'success', 'message' => sprintf($this->lang->job->sendExec, zget($this->lang->compile->statusList, $compile->status))));
|
||||
}
|
||||
|
||||
@@ -414,4 +421,21 @@ class job extends control
|
||||
$this->send(array('result' => 'success', 'type' => strtolower($repo->SCM)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax check SonarQube linked by repoID.
|
||||
*
|
||||
* @param int $repoID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxCheckSonarqubeLink($repoID, $jobID = 0)
|
||||
{
|
||||
$repo = $this->loadModel('job')->getSonarqubeByRepo(array($repoID), $jobID, true);
|
||||
if(!empty($repo))
|
||||
{
|
||||
$message = $repo[$repoID]->deleted ? $this->lang->job->jobIsDeleted : sprintf($this->lang->job->repoExists, $repo[$repoID]->id . '-' . $repo[$repoID]->name);
|
||||
$this->send(array('result' => 'fail', 'message' => $message));
|
||||
}
|
||||
$this->send(array('result' => 'success', 'message' => ''));
|
||||
}
|
||||
}
|
||||
|
||||
+87
-1
@@ -1,5 +1,51 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
/*
|
||||
* Get frame select.
|
||||
* param string engine eg. jenkins|gitlab
|
||||
*/
|
||||
function getFrameSelect(engine)
|
||||
{
|
||||
$('#frameBox .input-group').empty();
|
||||
$('#frameBox .input-group').append("<div class='load-indicator loading'></div>");
|
||||
var html = "<select id='frame' name='frame' class='form-control chosen'>";
|
||||
for(frame in frameList)
|
||||
{
|
||||
if(engine == 'jenkins' || frame != 'sonarqube') html += "<option value='" + frame + "'>" + frameList[frame] + "</option>";
|
||||
}
|
||||
html += '</select>';
|
||||
|
||||
$('#frameBox .loading').remove();
|
||||
$('#frameBox .input-group').append(html);
|
||||
$('#frameBox #frame').chosen();
|
||||
|
||||
$('#frame').change();
|
||||
}
|
||||
getFrameSelect('');
|
||||
|
||||
/*
|
||||
* Check sonarqube linked.
|
||||
*/
|
||||
function checkSonarquebLink()
|
||||
{
|
||||
var repoID = $('#repo').val();
|
||||
var frame = $('#frame').val();
|
||||
|
||||
if(frame != 'sonarqube' || repoID == 0) return false;
|
||||
|
||||
$.getJSON(createLink('job', 'ajaxCheckSonarqubeLink', 'repoID=' + repoID), function(result)
|
||||
{
|
||||
if(result.result != 'success')
|
||||
{
|
||||
alert(result.message);
|
||||
$('#repo').val(0).trigger('chosen:updated');
|
||||
$('#reference').val('').trigger('chosen:updated');
|
||||
$('.reference').hide();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$(document).on('change', '#repo', function()
|
||||
{
|
||||
var repoID = $(this).val();
|
||||
@@ -63,6 +109,9 @@ $(document).ready(function()
|
||||
$('#triggerggerType option[value=tag]').html(data.type == 'gitlab' ? buildTag : dirChange).trigger('chosen:updated');
|
||||
}
|
||||
});
|
||||
|
||||
/* Check exists sonarqube data. */
|
||||
checkSonarquebLink();
|
||||
});
|
||||
|
||||
$(document).on('change', '[name^=svnDir]', function()
|
||||
@@ -139,6 +188,42 @@ $(document).ready(function()
|
||||
|
||||
$('#jenkinsServerTR #jkTask').chosen({drop_direction: 'auto'});
|
||||
})
|
||||
|
||||
/* There has been a problem with handling the prompt label. */
|
||||
$('#jkTaskLabel').remove();
|
||||
})
|
||||
|
||||
$(document).on('change', '#frame', function()
|
||||
{
|
||||
var frame = $(this).val();
|
||||
if(frame == 'sonarqube')
|
||||
{
|
||||
$('tr.sonarqube').removeClass('hide');
|
||||
|
||||
/* Check exists sonarqube data. */
|
||||
checkSonarquebLink();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('tr.sonarqube').addClass('hide');
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on('change', '#sonarqubeServer', function()
|
||||
{
|
||||
var sonarqubeID = $(this).val();
|
||||
$('#sonarProject #projectKey').remove();
|
||||
$('#sonarProject #projectKey_chosen').remove();
|
||||
$('#sonarProject .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.get(createLink('sonarqube', 'ajaxGetProjectList', 'sonarqubeID=' + sonarqubeID), function(html)
|
||||
{
|
||||
$('#sonarProject .loading').remove();
|
||||
$('#sonarProject .input-group').append(html);
|
||||
$('#sonarProject #projectKey').chosen({drop_direction: 'auto'});
|
||||
})
|
||||
|
||||
/* There has been a problem with handling the prompt label. */
|
||||
$('#projectKeyLabel').remove();
|
||||
})
|
||||
|
||||
var scheduleOption = "<option value='schedule'>" + $('#triggerType').find('[value=schedule]').text() + "</option>";
|
||||
@@ -161,9 +246,10 @@ $(document).ready(function()
|
||||
$('tr.gitlabRepo').hide();
|
||||
$('tr.commonRepo').show();
|
||||
}
|
||||
|
||||
getFrameSelect(engine);
|
||||
});
|
||||
|
||||
$('#engine').change();
|
||||
|
||||
$('#triggerType').change();
|
||||
});
|
||||
|
||||
+89
-1
@@ -1,5 +1,52 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
/*
|
||||
* Get frame select.
|
||||
* param string engine eg. jenkins|gitlab
|
||||
*/
|
||||
function getFrameSelect()
|
||||
{
|
||||
$('#frameBox .input-group').empty();
|
||||
$('#frameBox .input-group').append("<div class='load-indicator loading'></div>");
|
||||
var html = "<select id='frame' name='frame' class='form-control chosen'>";
|
||||
for(frame in frameList)
|
||||
{
|
||||
if(job.engine == 'jenkins' || frame != 'sonarqube')
|
||||
{
|
||||
html += "<option value='" + frame + "'";
|
||||
if(frame == job.frame) html += " selected";
|
||||
html += ">" + frameList[frame] + "</option>";
|
||||
}
|
||||
}
|
||||
html += '</select>';
|
||||
|
||||
$('#frameBox .loading').remove();
|
||||
$('#frameBox .input-group').append(html);
|
||||
$('#frameBox #frame').chosen();
|
||||
}
|
||||
getFrameSelect();
|
||||
|
||||
/* Check sonarqube linked. */
|
||||
function checkSonarquebLink()
|
||||
{
|
||||
var repoID = $('#repo').val();
|
||||
var frame = $('#frame').val();
|
||||
|
||||
if(frame != 'sonarqube' || repoID == 0) return false;
|
||||
|
||||
$.getJSON(createLink('job', 'ajaxCheckSonarqubeLink', 'repoID=' + repoID + '&jobID=' + job.id), function(result)
|
||||
{
|
||||
if(result.result != 'success')
|
||||
{
|
||||
alert(result.message);
|
||||
$('#repo').val(0).trigger('chosen:updated');
|
||||
$('#reference').val('').trigger('chosen:updated');
|
||||
$('.reference').hide();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$('#gitlabRepo').change(function()
|
||||
{
|
||||
$('#repo').val($(this).val()).change();
|
||||
@@ -45,6 +92,9 @@ $(document).ready(function()
|
||||
$('#svnDirBox #svnDir').chosen();
|
||||
})
|
||||
}
|
||||
|
||||
/* Check exists sonarqube data. */
|
||||
checkSonarquebLink();
|
||||
})
|
||||
|
||||
$(document).on('change', '[name^=svnDir]', function()
|
||||
@@ -124,6 +174,43 @@ $(document).ready(function()
|
||||
|
||||
$('#jenkinsServerTR #jkTask').val(jkTask).chosen();
|
||||
})
|
||||
|
||||
/* There has been a problem with handling the prompt label. */
|
||||
$('#jkTaskLabel').remove();
|
||||
})
|
||||
|
||||
$(document).on('change', '#frame', function()
|
||||
{
|
||||
var frame = $(this).val();
|
||||
if(frame == 'sonarqube')
|
||||
{
|
||||
$('tr.sonarqube').removeClass('hide');
|
||||
|
||||
/* Check exists sonarqube data. */
|
||||
checkSonarquebLink();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('tr.sonarqube').addClass('hide');
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on('change', '#sonarqubeServer', function()
|
||||
{
|
||||
var sonarqubeID = $(this).val();
|
||||
var projectKey = sonarqubeID == job.sonarqubeServer ? job.projectKey.replace(/-/g, '*') : '';
|
||||
$('#sonarProject #projectKey').remove();
|
||||
$('#sonarProject #projectKey_chosen').remove();
|
||||
$('#sonarProject .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.get(createLink('sonarqube', 'ajaxGetProjectList', 'sonarqubeID=' + sonarqubeID + '&projectKey=' + projectKey), function(html)
|
||||
{
|
||||
$('#sonarProject .loading').remove();
|
||||
$('#sonarProject .input-group').append(html);
|
||||
$('#sonarProject #projectKey').chosen({drop_direction: 'auto'});
|
||||
})
|
||||
|
||||
/* There has been a problem with handling the prompt label. */
|
||||
$('#projectKeyLabel').remove();
|
||||
})
|
||||
|
||||
var scheduleOption = "<option value='schedule'>" + $('#triggerType').find('[value=schedule]').text() + "</option>";
|
||||
@@ -169,6 +256,7 @@ $(document).ready(function()
|
||||
|
||||
$('#engine').change();
|
||||
$('#jkServer').change();
|
||||
|
||||
$('#frame').change();
|
||||
$('#sonarqubeServer').change();
|
||||
$('#triggerType').change();
|
||||
});
|
||||
|
||||
+53
-46
@@ -14,46 +14,52 @@ $lang->job->execSuccess = 'Build success';
|
||||
|
||||
$lang->job->browseAction = 'Job List';
|
||||
|
||||
$lang->job->id = 'ID';
|
||||
$lang->job->name = 'Name';
|
||||
$lang->job->repo = 'Repo';
|
||||
$lang->job->product = $lang->productCommon;
|
||||
$lang->job->svnDir = 'SVN Tag Watch Path';
|
||||
$lang->job->jenkins = 'Jenkins';
|
||||
$lang->job->jkHost = 'Jenkins Server';
|
||||
$lang->job->jkJob = 'Jenkins Task';
|
||||
$lang->job->buildSpec = 'Build Target'; // 'pipeline@server'
|
||||
$lang->job->engine = 'Engine';
|
||||
$lang->job->server = 'Server';
|
||||
$lang->job->pipeline = 'Pipeline';
|
||||
$lang->job->buildType = 'Build Type';
|
||||
$lang->job->frame = 'Frame';
|
||||
$lang->job->triggerType = 'Trigger';
|
||||
$lang->job->atDay = 'Custom Days';
|
||||
$lang->job->atTime = 'At Time';
|
||||
$lang->job->lastStatus = 'Last Status';
|
||||
$lang->job->lastExec = 'Last Executed';
|
||||
$lang->job->comment = 'Match Keywords';
|
||||
$lang->job->customParam = 'Custom build parameters';
|
||||
$lang->job->paramName = 'Name';
|
||||
$lang->job->paramValue = 'Value';
|
||||
$lang->job->custom = 'Custom';
|
||||
$lang->job->createdBy = 'Created By';
|
||||
$lang->job->createdDate = 'Created Date';
|
||||
$lang->job->editedBy = 'Edited By';
|
||||
$lang->job->editedDate = 'Edited Date';
|
||||
$lang->job->lastTag = 'Last Tag';
|
||||
$lang->job->deleted = 'Deleted';
|
||||
$lang->job->repoServer = 'Repo Server';
|
||||
$lang->job->id = 'ID';
|
||||
$lang->job->name = 'Name';
|
||||
$lang->job->repo = 'Repo';
|
||||
$lang->job->product = $lang->productCommon;
|
||||
$lang->job->svnDir = 'SVN Tag Watch Path';
|
||||
$lang->job->jenkins = 'Jenkins';
|
||||
$lang->job->jkHost = 'Jenkins Server';
|
||||
$lang->job->jkJob = 'Jenkins Task';
|
||||
$lang->job->buildSpec = 'Build Target'; // 'pipeline@server'
|
||||
$lang->job->engine = 'Engine';
|
||||
$lang->job->server = 'Server';
|
||||
$lang->job->pipeline = 'Pipeline';
|
||||
$lang->job->buildType = 'Build Type';
|
||||
$lang->job->frame = 'Frame';
|
||||
$lang->job->triggerType = 'Trigger';
|
||||
$lang->job->atDay = 'Custom Days';
|
||||
$lang->job->atTime = 'At Time';
|
||||
$lang->job->lastStatus = 'Last Status';
|
||||
$lang->job->lastExec = 'Last Executed';
|
||||
$lang->job->comment = 'Match Keywords';
|
||||
$lang->job->customParam = 'Custom build parameters';
|
||||
$lang->job->paramName = 'Name';
|
||||
$lang->job->paramValue = 'Value';
|
||||
$lang->job->custom = 'Custom';
|
||||
$lang->job->createdBy = 'Created By';
|
||||
$lang->job->createdDate = 'Created Date';
|
||||
$lang->job->editedBy = 'Edited By';
|
||||
$lang->job->editedDate = 'Edited Date';
|
||||
$lang->job->lastTag = 'Last Tag';
|
||||
$lang->job->deleted = 'Deleted';
|
||||
$lang->job->repoServer = 'Repo Server';
|
||||
$lang->job->sonarqubeServer = 'SonarQube Server';
|
||||
$lang->job->projectKey = 'SonarQube Project';
|
||||
|
||||
$lang->job->lblBasic = 'Basic Info';
|
||||
|
||||
$lang->job->example = 'e.g.';
|
||||
$lang->job->commitEx = "Used to match the keywords used to create a compile. Multiple keywords are separated by ','";
|
||||
$lang->job->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
|
||||
$lang->job->sendExec = 'Send execute request success.';
|
||||
$lang->job->inputName = 'Please enter parameter name.';
|
||||
$lang->job->invalidName = 'The parameter name should be letters, numbers or underlines.';
|
||||
$lang->job->example = 'e.g.';
|
||||
$lang->job->commitEx = "Used to match the keywords used to create a compile. Multiple keywords are separated by ','";
|
||||
$lang->job->cronSample = 'e.g. 0 0 2 * * 2-6/1 means 2:00 a.m. every weekday.';
|
||||
$lang->job->sendExec = 'Send execute request success.';
|
||||
$lang->job->inputName = 'Please enter parameter name.';
|
||||
$lang->job->invalidName = 'The parameter name should be letters, numbers or underlines.';
|
||||
$lang->job->repoExists = 'This repository has a build task associated with it『%s』';
|
||||
$lang->job->projectExists = 'This SonarQube Project has a build task associated with it『%s』';
|
||||
$lang->job->mustUseJenkins = 'SonarQube frame is only used if the build engine is JenKins.';
|
||||
$lang->job->jobIsDeleted = 'This repository is associated with a build task, please view the data from the recycle bin';
|
||||
|
||||
$lang->job->buildTypeList['build'] = 'Only Build';
|
||||
$lang->job->buildTypeList['buildAndDeploy'] = 'Build And Deploy';
|
||||
@@ -63,15 +69,16 @@ $lang->job->triggerTypeList['tag'] = 'Tag';
|
||||
$lang->job->triggerTypeList['commit'] = 'Code Commit';
|
||||
$lang->job->triggerTypeList['schedule'] = 'Schedule';
|
||||
|
||||
$lang->job->frameList[''] = '';
|
||||
$lang->job->frameList['junit'] = 'JUnit';
|
||||
$lang->job->frameList['testng'] = 'TestNG';
|
||||
$lang->job->frameList['phpunit'] = 'PHPUnit';
|
||||
$lang->job->frameList['pytest'] = 'Pytest';
|
||||
$lang->job->frameList['jtest'] = 'JTest';
|
||||
$lang->job->frameList['cppunit'] = 'CppUnit';
|
||||
$lang->job->frameList['gtest'] = 'GTest';
|
||||
$lang->job->frameList['qtest'] = 'QTest';
|
||||
$lang->job->frameList[''] = '';
|
||||
$lang->job->frameList['junit'] = 'JUnit';
|
||||
$lang->job->frameList['testng'] = 'TestNG';
|
||||
$lang->job->frameList['phpunit'] = 'PHPUnit';
|
||||
$lang->job->frameList['pytest'] = 'Pytest';
|
||||
$lang->job->frameList['jtest'] = 'JTest';
|
||||
$lang->job->frameList['cppunit'] = 'CppUnit';
|
||||
$lang->job->frameList['gtest'] = 'GTest';
|
||||
$lang->job->frameList['qtest'] = 'QTest';
|
||||
$lang->job->frameList['sonarqube'] = 'SonarQube';
|
||||
|
||||
$lang->job->paramValueList[''] = '';
|
||||
$lang->job->paramValueList['$zentao_version'] = 'Current version';
|
||||
|
||||
+53
-46
@@ -14,46 +14,52 @@ $lang->job->execSuccess = '执行成功';
|
||||
|
||||
$lang->job->browseAction = '构建任务列表';
|
||||
|
||||
$lang->job->id = 'ID';
|
||||
$lang->job->name = '名称';
|
||||
$lang->job->repo = '代码库';
|
||||
$lang->job->product = '关联' . $lang->productCommon;
|
||||
$lang->job->svnDir = 'SVN监控路径';
|
||||
$lang->job->jenkins = 'Jenkins';
|
||||
$lang->job->jkHost = 'Jenkins服务器';
|
||||
$lang->job->jkJob = 'Jenkins任务';
|
||||
$lang->job->buildSpec = '构建对象'; // 'pipeline@server'
|
||||
$lang->job->engine = '构建引擎';
|
||||
$lang->job->server = '服务器';
|
||||
$lang->job->pipeline = '流水线';
|
||||
$lang->job->buildType = '构建类型';
|
||||
$lang->job->frame = '工具/框架';
|
||||
$lang->job->triggerType = '触发方式';
|
||||
$lang->job->atDay = '自定义日期';
|
||||
$lang->job->atTime = '执行时间';
|
||||
$lang->job->lastStatus = '最后执行状态';
|
||||
$lang->job->lastExec = '最后执行时间';
|
||||
$lang->job->comment = '匹配关键字';
|
||||
$lang->job->customParam = '自定义构建参数';
|
||||
$lang->job->paramName = '名称';
|
||||
$lang->job->paramValue = '值';
|
||||
$lang->job->custom = '自定义';
|
||||
$lang->job->createdBy = '由谁创建';
|
||||
$lang->job->createdDate = '创建日期';
|
||||
$lang->job->editedBy = '由谁编辑';
|
||||
$lang->job->editedDate = '编辑日期';
|
||||
$lang->job->lastTag = '最后标签';
|
||||
$lang->job->deleted = '已删除';
|
||||
$lang->job->repoServer = '版本库服务器';
|
||||
$lang->job->id = 'ID';
|
||||
$lang->job->name = '名称';
|
||||
$lang->job->repo = '代码库';
|
||||
$lang->job->product = '关联' . $lang->productCommon;
|
||||
$lang->job->svnDir = 'SVN监控路径';
|
||||
$lang->job->jenkins = 'Jenkins';
|
||||
$lang->job->jkHost = 'Jenkins服务器';
|
||||
$lang->job->jkJob = 'Jenkins任务';
|
||||
$lang->job->buildSpec = '构建对象'; // 'pipeline@server'
|
||||
$lang->job->engine = '构建引擎';
|
||||
$lang->job->server = '服务器';
|
||||
$lang->job->pipeline = '流水线';
|
||||
$lang->job->buildType = '构建类型';
|
||||
$lang->job->frame = '工具/框架';
|
||||
$lang->job->triggerType = '触发方式';
|
||||
$lang->job->atDay = '自定义日期';
|
||||
$lang->job->atTime = '执行时间';
|
||||
$lang->job->lastStatus = '最后执行状态';
|
||||
$lang->job->lastExec = '最后执行时间';
|
||||
$lang->job->comment = '匹配关键字';
|
||||
$lang->job->customParam = '自定义构建参数';
|
||||
$lang->job->paramName = '名称';
|
||||
$lang->job->paramValue = '值';
|
||||
$lang->job->custom = '自定义';
|
||||
$lang->job->createdBy = '由谁创建';
|
||||
$lang->job->createdDate = '创建日期';
|
||||
$lang->job->editedBy = '由谁编辑';
|
||||
$lang->job->editedDate = '编辑日期';
|
||||
$lang->job->lastTag = '最后标签';
|
||||
$lang->job->deleted = '已删除';
|
||||
$lang->job->repoServer = '版本库服务器';
|
||||
$lang->job->sonarqubeServer = 'SonarQube服务器';
|
||||
$lang->job->projectKey = 'SonarQube项目';
|
||||
|
||||
$lang->job->lblBasic = '基本信息';
|
||||
|
||||
$lang->job->example = '举例';
|
||||
$lang->job->commitEx = "用于匹配创建构建任务的关键字,多个关键字用','分割";
|
||||
$lang->job->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
|
||||
$lang->job->sendExec = '发送执行请求成功!执行结果:%s';
|
||||
$lang->job->inputName = '请输入参数名称。';
|
||||
$lang->job->invalidName = '参数名称应该是英文字母、数字或下划线的组合。';
|
||||
$lang->job->example = '举例';
|
||||
$lang->job->commitEx = "用于匹配创建构建任务的关键字,多个关键字用','分割";
|
||||
$lang->job->cronSample = '如 0 0 2 * * 2-6/1 表示每个工作日凌晨2点';
|
||||
$lang->job->sendExec = '发送执行请求成功!执行结果:%s';
|
||||
$lang->job->inputName = '请输入参数名称。';
|
||||
$lang->job->invalidName = '参数名称应该是英文字母、数字或下划线的组合。';
|
||||
$lang->job->repoExists = '此版本库已关联构建任务『%s』';
|
||||
$lang->job->projectExists = '此SonarQube项目已关联构建任务『%s』';
|
||||
$lang->job->mustUseJenkins = 'SonarQube工具/框架仅在构建引擎为JenKins的情况下使用';
|
||||
$lang->job->jobIsDeleted = '此版本库已关联构建任务,请从回收站查看数据';
|
||||
|
||||
$lang->job->buildTypeList['build'] = '仅构建';
|
||||
$lang->job->buildTypeList['buildAndDeploy'] = '构建部署';
|
||||
@@ -63,15 +69,16 @@ $lang->job->triggerTypeList['tag'] = '打标签';
|
||||
$lang->job->triggerTypeList['commit'] = '提交注释包含关键字';
|
||||
$lang->job->triggerTypeList['schedule'] = '定时计划';
|
||||
|
||||
$lang->job->frameList[''] = '';
|
||||
$lang->job->frameList['junit'] = 'JUnit';
|
||||
$lang->job->frameList['testng'] = 'TestNG';
|
||||
$lang->job->frameList['phpunit'] = 'PHPUnit';
|
||||
$lang->job->frameList['pytest'] = 'Pytest';
|
||||
$lang->job->frameList['jtest'] = 'JTest';
|
||||
$lang->job->frameList['cppunit'] = 'CppUnit';
|
||||
$lang->job->frameList['gtest'] = 'GTest';
|
||||
$lang->job->frameList['qtest'] = 'QTest';
|
||||
$lang->job->frameList[''] = '';
|
||||
$lang->job->frameList['junit'] = 'JUnit';
|
||||
$lang->job->frameList['testng'] = 'TestNG';
|
||||
$lang->job->frameList['phpunit'] = 'PHPUnit';
|
||||
$lang->job->frameList['pytest'] = 'Pytest';
|
||||
$lang->job->frameList['jtest'] = 'JTest';
|
||||
$lang->job->frameList['cppunit'] = 'CppUnit';
|
||||
$lang->job->frameList['gtest'] = 'GTest';
|
||||
$lang->job->frameList['qtest'] = 'QTest';
|
||||
$lang->job->frameList['sonarqube'] = 'SonarQube';
|
||||
|
||||
$lang->job->paramValueList[''] = '';
|
||||
$lang->job->paramValueList['$zentao_version'] = '当前版本号';
|
||||
|
||||
+101
-3
@@ -156,7 +156,8 @@ class jobModel extends model
|
||||
public function create()
|
||||
{
|
||||
$job = fixer::input('post')
|
||||
->setDefault('atDay', '')
|
||||
->setDefault('atDay,projectKey', '')
|
||||
->setDefault('sonarqubeServer', 0)
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->remove('repoType,reference')
|
||||
@@ -181,6 +182,35 @@ class jobModel extends model
|
||||
unset($job->jkTask);
|
||||
unset($job->gitlabRepo);
|
||||
|
||||
/* SonarQube tool is only used if the engine is JenKins. */
|
||||
if($job->engine != 'jenkins' and $job->frame == 'sonarqube')
|
||||
{
|
||||
dao::$errors[]['frame'] = $this->lang->job->mustUseJenkins;
|
||||
return false;
|
||||
}
|
||||
|
||||
if($job->repo > 0 and $job->frame == 'sonarqube')
|
||||
{
|
||||
$sonarqubeJob = $this->getSonarqubeByRepo(array($job->repo));
|
||||
if(!empty($sonarqubeJob))
|
||||
{
|
||||
$message = sprintf($this->lang->job->repoExists, $sonarqubeJob[$job->repo]->id . '-' . $sonarqubeJob[$job->repo]->name);
|
||||
dao::$errors[]['repo'] = $message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($job->projectKey) and $job->frame == 'sonarqube')
|
||||
{
|
||||
$projectList = $this->getJobBySonarqubeProject($job->sonarqubeServer, array($job->projectKey));
|
||||
if(!empty($projectList))
|
||||
{
|
||||
$message = sprintf($this->lang->job->projectExists, $projectList[$job->projectKey]->id);
|
||||
dao::$errors[]['projectKey'] = $message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
|
||||
|
||||
$job->svnDir = '';
|
||||
@@ -219,6 +249,7 @@ class jobModel extends model
|
||||
->batchCheckIF($job->triggerType === 'schedule', "atDay,atTime", 'notempty')
|
||||
->batchCheckIF($job->triggerType === 'commit', "comment", 'notempty')
|
||||
->batchCheckIF(($this->post->repoType == 'Subversion' and $job->triggerType == 'tag'), "svnDir", 'notempty')
|
||||
->batchCheckIF($job->frame === 'sonarqube', "sonarqubeServer,projectKey", 'notempty')
|
||||
->autoCheck()
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
@@ -268,6 +299,35 @@ class jobModel extends model
|
||||
unset($job->jkTask);
|
||||
unset($job->gitlabRepo);
|
||||
|
||||
/* SonarQube tool is only used if the engine is JenKins. */
|
||||
if($job->engine != 'jenkins' and $job->frame == 'sonarqube')
|
||||
{
|
||||
dao::$errors[] = $this->lang->job->mustUseJenkins;
|
||||
return false;
|
||||
}
|
||||
|
||||
if($job->repo > 0 and $job->frame == 'sonarqube')
|
||||
{
|
||||
$sonarqubeJob = $this->getSonarqubeByRepo(array($job->repo), $id);
|
||||
if(!empty($sonarqubeJob))
|
||||
{
|
||||
$message = sprintf($this->lang->job->repoExists, $sonarqubeJob[$job->repo]->id . '-' . $sonarqubeJob[$job->repo]->name);
|
||||
dao::$errors[]['repo'] = $message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($job->projectKey) and $job->frame == 'sonarqube')
|
||||
{
|
||||
$projectList = $this->getJobBySonarqubeProject($job->sonarqubeServer, array($job->projectKey));
|
||||
if(!empty($projectList) && $projectList[$job->projectKey]->id != $id)
|
||||
{
|
||||
$message = sprintf($this->lang->job->projectExists, $projectList[$job->projectKey]->id);
|
||||
dao::$errors[]['projectKey'] = $message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
|
||||
|
||||
$job->svnDir = '';
|
||||
@@ -304,11 +364,10 @@ class jobModel extends model
|
||||
|
||||
$this->dao->update(TABLE_JOB)->data($job)
|
||||
->batchCheck($this->config->job->edit->requiredFields, 'notempty')
|
||||
|
||||
->batchCheckIF($job->triggerType === 'schedule', "atDay,atTime", 'notempty')
|
||||
->batchCheckIF($job->triggerType === 'commit', "comment", 'notempty')
|
||||
->batchCheckIF(($this->post->repoType == 'Subversion' and $job->triggerType == 'tag'), "svnDir", 'notempty')
|
||||
|
||||
->batchCheckIF($job->frame === 'sonarqube', "sonarqubeServer,projectKey", 'notempty')
|
||||
->autoCheck()
|
||||
->where('id')->eq($id)
|
||||
->exec();
|
||||
@@ -539,4 +598,43 @@ class jobModel extends model
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sonarqube by RepoID.
|
||||
*
|
||||
* @param array $repoIDList
|
||||
* @param int $jobID
|
||||
* @param bool $showDeleted
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSonarqubeByRepo($repoIDList, $jobID = 0, $showDeleted = false)
|
||||
{
|
||||
return $this->dao->select('id,name,repo,deleted')->from(TABLE_JOB)
|
||||
->where('frame')->eq('sonarqube')
|
||||
->andWhere('repo')->in($repoIDList)
|
||||
->beginIF(!$showDeleted)->andWhere('deleted')->eq('0')->fi()
|
||||
->beginIF($jobID > 0)->andWhere('id')->ne($jobID)->fi()
|
||||
->fetchAll('repo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get job pairs by sonarqube projectkeys.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param array $projectKeys
|
||||
* @param bool $emptyShowAll
|
||||
* @param bool $showDeleted
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false, $showDeleted = false)
|
||||
{
|
||||
return $this->dao->select('projectKey,id')->from(TABLE_JOB)
|
||||
->where('frame')->eq('sonarqube')
|
||||
->andWhere('sonarqubeServer')->eq($sonarqubeID)
|
||||
->beginIF(!$showDeleted)->andWhere('deleted')->eq('0')->fi()
|
||||
->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi()
|
||||
->fetchPairs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<?php js::set('triggerType', 'tag');?>
|
||||
<?php js::set('dirChange', $lang->job->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->job->buildTag);?>
|
||||
<?php js::set('frameList', $lang->job->frameList);?>
|
||||
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-content'>
|
||||
@@ -26,7 +27,7 @@
|
||||
<form id='jobForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->job->name; ?></th>
|
||||
<th class='w-140px'><?php echo $lang->job->name; ?></th>
|
||||
<td class='required'><?php echo html::input('name', '', "class='form-control'"); ?></td>
|
||||
<td colspan="2" ></td>
|
||||
</tr>
|
||||
@@ -51,9 +52,13 @@
|
||||
<th><?php echo $lang->job->product; ?></th>
|
||||
<td><?php echo html::select('product', '', '', "class='form-control chosen'"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="frameBox">
|
||||
<th><?php echo $lang->job->frame; ?></th>
|
||||
<td><?php echo html::select('frame', $lang->job->frameList, '', "class='form-control chosen'"); ?></td>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('frame', array('' => ''), '', "class='form-control chosen'"); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->job->triggerType; ?></th>
|
||||
@@ -68,6 +73,20 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class='sonarqube hide'>
|
||||
<th><?php echo $lang->job->sonarqubeServer;?></th>
|
||||
<td><?php echo html::select('sonarqubeServer', $sonarqubeServerList, '', "class='form-control chosen' required");?></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr id='sonarProject' class='sonarqube hide'>
|
||||
<th><?php echo $lang->job->projectKey;?></th>
|
||||
<td class='required'>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('projectKey', array('' => ''), '', "class='form-control chosen'");?>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr class="comment-fields">
|
||||
<th><?php echo $lang->job->comment;?></th>
|
||||
<td class='required'><?php echo html::input('comment', '', "class='form-control'");?></td>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<?php js::set('dirChange', $lang->job->dirChange);?>
|
||||
<?php js::set('buildTag', $lang->job->buildTag);?>
|
||||
<?php js::set('jkTask', $job->pipeline);?>
|
||||
<?php js::set('job', $job);?>
|
||||
<?php js::set('frameList', $lang->job->frameList);?>
|
||||
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-content'>
|
||||
@@ -28,7 +30,7 @@
|
||||
<form id='jobForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-120px'><?php echo $lang->job->name;?></th>
|
||||
<th class='w-140px'><?php echo $lang->job->name;?></th>
|
||||
<td class='required'><?php echo html::input('name', $job->name, "class='form-control'");?></td>
|
||||
<td colspan="2" ></td>
|
||||
</tr>
|
||||
@@ -50,9 +52,13 @@
|
||||
<th><?php echo $lang->job->product;?></th>
|
||||
<td><?php echo html::select('product', $products, $job->product, "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="frameBox">
|
||||
<th><?php echo $lang->job->frame;?></th>
|
||||
<td><?php echo html::select('frame', $lang->job->frameList, $job->frame, "class='form-control chosen'");?></td>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('frame', array('' => ''), '', "class='form-control chosen'"); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->job->triggerType;?></th>
|
||||
@@ -88,6 +94,20 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class='sonarqube hide'>
|
||||
<th><?php echo $lang->job->sonarqubeServer;?></th>
|
||||
<td><?php echo html::select('sonarqubeServer', $sonarqubeServerList, $job->sonarqubeServer, "class='form-control chosen' required");?></td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr id='sonarProject' class='sonarqube hide'>
|
||||
<th><?php echo $lang->job->projectKey;?></th>
|
||||
<td class="required">
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('projectKey', array('' => ''), '', "class='form-control chosen'");?>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
<tr class="comment-fields">
|
||||
<th><?php echo $lang->job->comment;?></th>
|
||||
<td class='required'><?php echo html::input('comment', $job->comment, "class='form-control'");?></td>
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
<span class="label label-closed"><?php echo $lang->kanban->closed;?></span>
|
||||
<?php endif;?>
|
||||
<?php echo $space->name;?>
|
||||
<?php echo isset($space->kanbans) ? count($space->kanbans) : '';?>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -258,6 +258,7 @@ class mrModel extends model
|
||||
{
|
||||
$MR = fixer::input('post')
|
||||
->setDefault('jobID', 0)
|
||||
->setDefault('compileID', 0)
|
||||
->setDefault('repoID', 0)
|
||||
->setDefault('removeSourceBranch','0')
|
||||
->setDefault('needCI', 0)
|
||||
|
||||
@@ -133,7 +133,8 @@
|
||||
<table class="table table-data">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="w-90px"><?php echo $lang->job->common;?></th>
|
||||
<?php $class = in_array($this->app->getClientLang(), array('zh-cn','zh-tw')) ? 'w-90px' : 'w-100px'; ?>
|
||||
<th class="<?php echo $class; ?>"><?php echo $lang->job->common;?></th>
|
||||
<td><?php echo $compile->name;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
{
|
||||
echo '#' . $action->objectID;
|
||||
}
|
||||
elseif(empty($action->objectID) and $action->extra)
|
||||
{
|
||||
echo $action->extra;
|
||||
}
|
||||
elseif(empty($action->objectLink))
|
||||
{
|
||||
echo $action->objectName;
|
||||
@@ -73,8 +77,10 @@
|
||||
echo html::a($action->objectLink, $action->objectName, '', $tab);
|
||||
}
|
||||
?>
|
||||
<?php if($action->objectID):?>
|
||||
<span class="label label-id"><?php echo $action->objectID;?></span>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -76,7 +76,7 @@ class pipelineModel extends model
|
||||
->add('private',md5(rand(10,113450)))
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->trim('token')
|
||||
->trim('url,token,account,password')
|
||||
->skipSpecial('url,token,account,password')
|
||||
->get();
|
||||
if($type == 'gitlab') $pipeline->url = rtrim($pipeline->url, '/');
|
||||
@@ -105,7 +105,7 @@ class pipelineModel extends model
|
||||
$pipeline = fixer::input('post')
|
||||
->add('editedBy', $this->app->user->account)
|
||||
->add('editedDate', helper::now())
|
||||
->trim('token')
|
||||
->trim('url,token,account,password')
|
||||
->skipSpecial('url,token,account,password')
|
||||
->get();
|
||||
|
||||
@@ -122,4 +122,21 @@ class pipelineModel extends model
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete one record.
|
||||
*
|
||||
* @param string $id the id to be deleted
|
||||
* @param string $object the action object
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id, $object = 'gitlab')
|
||||
{
|
||||
$this->dao->update(TABLE_PIPELINE)->set('deleted')->eq(1)->where('id')->eq($id)->exec();
|
||||
$this->loadModel('action')->create($object, $id, 'deleted', '', ACTIONMODEL::CAN_UNDELETED);
|
||||
|
||||
$actionID = $this->dao->lastInsertID();
|
||||
return $actionID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ class repo extends control
|
||||
$repoID = $this->repo->saveState(0, $objectID);
|
||||
if($this->viewType !== 'json') $this->commonAction($repoID, $objectID);
|
||||
|
||||
$repoList = $this->repo->getList(0, '', $orderBy);
|
||||
$repoList = $this->repo->getList(0, '', $orderBy);
|
||||
$sonarRepoList = $this->loadModel('job')->getSonarqubeByRepo(array_keys($repoList));
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -95,11 +96,12 @@ class repo extends control
|
||||
$this->view->position[] = $this->lang->repo->common;
|
||||
$this->view->position[] = $this->lang->repo->browse;
|
||||
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->repoList = empty($repoList) ? $repoList: $repoList[$pageID - 1];;
|
||||
$this->view->products = $this->loadModel('product')->getPairs();
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->repoList = empty($repoList) ? $repoList: $repoList[$pageID - 1];;
|
||||
$this->view->products = $this->loadModel('product')->getPairs();
|
||||
$this->view->sonarRepoList = $sonarRepoList;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -403,8 +405,6 @@ class repo extends control
|
||||
/* Cache infos. */
|
||||
if($refresh or !$cacheFile or !file_exists($cacheFile) or (time() - filemtime($cacheFile)) / 60 > $this->config->repo->cacheTime)
|
||||
{
|
||||
$this->repo->syncCommit($repoID, $branchID);
|
||||
|
||||
/* Get cache infos. */
|
||||
$infos = $this->scm->ls($path, $revision);
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ class repoModel extends model
|
||||
|
||||
/* Convert to id by url. */
|
||||
$this->loadModel('gitlab');
|
||||
$url = strtolower($url);
|
||||
$url = str_replace('https://', 'http://', strtolower($url));
|
||||
$matches = array();
|
||||
foreach($gitlabs as $gitlabID => $gitlab)
|
||||
{
|
||||
@@ -435,7 +435,8 @@ class repoModel extends model
|
||||
$projects = $this->gitlab->apiGetProjects($gitlabID);
|
||||
foreach($projects as $project)
|
||||
{
|
||||
if((!$isSSH and strtolower($project->http_url_to_repo) == $url) or ($isSSH and strtolower($project->ssh_url_to_repo) == $url))
|
||||
$urlToRepo = str_replace('https://', 'http://', strtolower($project->http_url_to_repo));
|
||||
if((!$isSSH and $urlToRepo == $url) or ($isSSH and strtolower($project->ssh_url_to_repo) == $url))
|
||||
{
|
||||
$matched->gitlab = $gitlabID;
|
||||
$matched->project = $project->id;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->repo->name); ?></th>
|
||||
<th class='c-product text-left'><?php common::printOrderLink('product', $orderBy, $vars, $lang->repo->product); ?></th>
|
||||
<th class='text-left'><?php echo $lang->repo->path; ?></th>
|
||||
<th class='c-actions-3 w-150px'><?php echo $lang->actions; ?></th>
|
||||
<th class='c-actions-6'><?php echo $lang->actions; ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -59,6 +59,11 @@
|
||||
common::printIcon('gitlab', 'createWebhook', "repoID=$repo->id", '', 'list', 'change', 'hiddenwin');
|
||||
common::printIcon('gitlab', 'importIssue', "repo={$repo->id}", '', 'list', 'link');
|
||||
}
|
||||
if(isset($sonarRepoList[$repo->id]))
|
||||
{
|
||||
$jobID = $sonarRepoList[$repo->id]->id;
|
||||
common::printIcon('sonarqube', 'execJob', "jobID=$jobID", '', 'list', 'sonarqube', 'hiddenwin');
|
||||
}
|
||||
common::printIcon('repo', 'delete', "repoID=$repo->id&objectID=$objectID", '', 'list', 'trash', 'hiddenwin');
|
||||
?>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$config->sonarqube = new stdclass();
|
||||
|
||||
$config->sonarqube->create = new stdclass();
|
||||
$config->sonarqube->create->requiredFields = 'name,url,account,password';
|
||||
|
||||
$config->sonarqube->edit = new stdclass();
|
||||
$config->sonarqube->edit->requiredFields = 'name,url,account,password';
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package sonarqube
|
||||
* @version $Id: ${FILE_NAME} 5144 2022/1/11 8:55 上午 caoyanyi@easycorp.ltd $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class sonarqube extends control
|
||||
{
|
||||
/**
|
||||
* The mr constructor.
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
*/
|
||||
public function __construct($moduleName = '', $methodName = '')
|
||||
{
|
||||
parent::__construct($moduleName, $methodName);
|
||||
|
||||
/* This is essential when changing tab(menu) from gitlab to repo. */
|
||||
/* Optional: common::setMenuVars('devops', $this->session->repoID); */
|
||||
$this->loadModel('ci')->setMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse sonarqube.
|
||||
*
|
||||
* @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);
|
||||
|
||||
$sonarqubeList = $this->loadModel('pipeline')->getList('sonarqube', $orderBy, $pager);
|
||||
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browse;
|
||||
$this->view->sonarqubeList = $sonarqubeList;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->pager = $pager;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get project select.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $projectKey
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetProjectList($sonarqubeID, $projectKey = '')
|
||||
{
|
||||
$jobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, array(), true, true);
|
||||
$existsProject = array_diff(array_keys($jobPairs), array($projectKey));
|
||||
|
||||
$projectList = $this->sonarqube->apiGetProjects($sonarqubeID);
|
||||
|
||||
$projectPairs = array('' => '');
|
||||
foreach($projectList as $project)
|
||||
{
|
||||
if(!empty($project) and !in_array($project->key, $existsProject)) $projectPairs[$project->key] = $project->name;
|
||||
}
|
||||
|
||||
echo html::select('projectKey', $projectPairs, str_replace('*', '-', $projectKey), "class='form-control chosen'");
|
||||
}
|
||||
|
||||
/**
|
||||
* create a sonarqube.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->checkToken();
|
||||
$sonarqubeID = $this->loadModel('pipeline')->create('sonarqube');
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$actionID = $this->loadModel('action')->create('sonarqube', $sonarqubeID, 'created');
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->createServer;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check post info.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function checkToken($sonarqubeID = 0)
|
||||
{
|
||||
$sonarqube = fixer::input('post')->trim('url,token,account,password')->get();
|
||||
$this->dao->update('sonarqube')->data($sonarqube)
|
||||
->batchCheck(empty($sonarqubeID) ? $this->config->sonarqube->create->requiredFields : $this->config->sonarqube->edit->requiredFields, 'notempty')
|
||||
->batchCheck("url", 'URL');
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if(strpos($sonarqube->url, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->sonarqube->hostError))));
|
||||
|
||||
/* Check name and url unique. */
|
||||
$existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE)
|
||||
->where("type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')")
|
||||
->andWhere('deleted')->eq('0')
|
||||
->beginIF(!empty($sonarqubeID))->andWhere('id')->ne($sonarqubeID)->fi()
|
||||
->fetch();
|
||||
if(isset($existSonarQube->name) and $existSonarQube->name == $sonarqube->name) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->nameRepeatError));
|
||||
if(isset($existSonarQube->url) and $existSonarQube->url == $sonarqube->url) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->urlRepeatError));
|
||||
|
||||
$token = base64_encode("{$sonarqube->account}:{$sonarqube->password}");
|
||||
$result = $this->sonarqube->apiValidate($sonarqube->url, $token);
|
||||
|
||||
if(!isset($result->valid) or !$result->valid) return $this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->sonarqube->validError))));
|
||||
$this->post->set('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a sonarqube.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($sonarqubeID)
|
||||
{
|
||||
$oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$this->checkToken($sonarqubeID);
|
||||
$this->pipeline->update($sonarqubeID);
|
||||
$sonarqube = $this->pipeline->getByID($sonarqubeID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->loadModel('action');
|
||||
$actionID = $this->action->create('sonarqube', $sonarqubeID, 'edited');
|
||||
$changes = common::createChanges($oldSonarQube, $sonarqube);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->editServer;
|
||||
$this->view->sonarqube = $oldSonarQube;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a sonarqube.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function delete($sonarqubeID, $confirm = 'no')
|
||||
{
|
||||
if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDelete, inlink('delete', "sonarqubeID=$sonarqubeID&confirm=yes")));
|
||||
|
||||
$oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID);
|
||||
$this->loadModel('action');
|
||||
$actionID = $this->pipeline->delete($sonarqubeID, 'sonarqube');
|
||||
|
||||
$sonarQube = $this->pipeline->getByID($sonarqubeID);
|
||||
$changes = common::createChanges($oldSonarQube, $sonarQube);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
echo js::reload('parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exec job.
|
||||
*
|
||||
* @param int $jobID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function execJob($jobID)
|
||||
{
|
||||
echo $this->fetch('job', 'exec', "jobID=$jobID");
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse sonarqube project.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browseProject($sonarqubeID, $orderBy = 'name_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$keyword = fixer::input('post')->setDefault('keyword', '')->get('keyword');
|
||||
|
||||
$sonarqubeProjectList = $this->sonarqube->apiGetProjects($sonarqubeID, $keyword);
|
||||
$projectKeyList = array();
|
||||
foreach($sonarqubeProjectList as $key => $sonarqubeProject)
|
||||
{
|
||||
if(!isset($sonarqubeProject->lastAnalysisDate)) $sonarqubeProject->lastAnalysisDate = '';
|
||||
$projectKeyList[] = $sonarqubeProject->key;
|
||||
}
|
||||
|
||||
/* Data sort. */
|
||||
list($order, $sort) = explode('_', $orderBy);
|
||||
$orderList = array();
|
||||
foreach($sonarqubeProjectList as $sonarqubeProject) $orderList[] = $sonarqubeProject->$order;
|
||||
array_multisort($orderList, $sort == 'desc' ? SORT_DESC : SORT_ASC, $sonarqubeProjectList);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$recTotal = count($sonarqubeProjectList);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$sonarqubeProjectList = array_chunk($sonarqubeProjectList, $pager->recPerPage);
|
||||
|
||||
$this->view->sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID);
|
||||
$this->view->keyword = urldecode(urldecode($keyword));
|
||||
$this->view->pager = $pager;
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browseProject;
|
||||
$this->view->sonarqubeID = $sonarqubeID;
|
||||
$this->view->sonarqubeProjectList = (empty($sonarqubeProjectList) or empty($sonarqubeProjectList[$pageID - 1])) ? array() : $sonarqubeProjectList[$pageID - 1];
|
||||
$this->view->projectJobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, $projectKeyList);
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete project.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $projectKey
|
||||
* @param string $confirm
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteProject($sonarqubeID, $projectKey, $confirm = 'no')
|
||||
{
|
||||
if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDeleteProject, inlink('deleteProject', "sonarqubeID=$sonarqubeID&projectKey=$projectKey&confirm=yes")));
|
||||
|
||||
/* Fix error when request type is PATH_INFO and the tag name contains '-'.*/
|
||||
$projectKey = str_replace('*', '-', $projectKey);
|
||||
$reponse = $this->sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
|
||||
if(isset($reponse->errors)) return print(js::alert($reponse->errors[0]->msg));
|
||||
|
||||
$this->loadModel('action')->create('sonarqubeproject', 0, 'deleted', '', $projectKey);
|
||||
return print(js::reload('parent'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
.text-c-counts > span {margin-left: 5px;}
|
||||
#mainMenu .pull-left {margin-right: 15px;}
|
||||
@@ -0,0 +1,2 @@
|
||||
.table-form .c-name {width: 130px;}
|
||||
.table-form .c-input {width: 650px;}
|
||||
@@ -0,0 +1,2 @@
|
||||
.table-form .c-name {width: 130px;}
|
||||
.table-form .c-input {width: 650px;}
|
||||
@@ -0,0 +1,22 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#projectSearch').click(function()
|
||||
{
|
||||
triggerSearch();
|
||||
});
|
||||
$('#keyword').keypress(function(event)
|
||||
{
|
||||
if(event.which == 13) triggerSearch();
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* Trigger filtering function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function triggerSearch()
|
||||
{
|
||||
$("#sonarqubeProjectForm").submit();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$lang->sonarqube = new stdclass;
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = 'SonarQube Browse';
|
||||
$lang->sonarqube->search = 'Search';
|
||||
$lang->sonarqube->create = 'Create SonarQube';
|
||||
$lang->sonarqube->edit = 'Edit SonarQube';
|
||||
$lang->sonarqube->delete = 'Delete SonarQube';
|
||||
$lang->sonarqube->serverFail = 'Connect to SonarQube server failed, please check the SonarQube server.';
|
||||
$lang->sonarqube->browseProject = "SonarQube Project List";
|
||||
$lang->sonarqube->createProject = "Create SonarQube Project";
|
||||
$lang->sonarqube->deleteProject = "Delete SonarQube Project";
|
||||
$lang->sonarqube->placeholderSearch = 'Project name';
|
||||
$lang->sonarqube->execJob = "Exec SonarQube Job";
|
||||
$lang->sonarqube->desc = 'Description';
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "Server Name";
|
||||
$lang->sonarqube->url = 'Server Address';
|
||||
$lang->sonarqube->account = 'Username';
|
||||
$lang->sonarqube->password = 'Password';
|
||||
$lang->sonarqube->token = 'Token';
|
||||
$lang->sonarqube->defaultProject = 'Default Project';
|
||||
$lang->sonarqube->private = 'MD5 Verify';
|
||||
|
||||
$lang->sonarqube->createServer = 'Create SonarQube Server';
|
||||
$lang->sonarqube->editServer = 'Edit SonarQube Server';
|
||||
$lang->sonarqube->createSuccess = 'Create success';
|
||||
|
||||
$lang->sonarqube->placeholder = new stdclass;
|
||||
$lang->sonarqube->placeholder->name = '';
|
||||
$lang->sonarqube->placeholder->url = "Please fill in the access address of the SonarQube Server homepage, as: https://sonarqube.zentao.net.";
|
||||
|
||||
$lang->sonarqube->nameRepeatError = "Server name already exists!";
|
||||
$lang->sonarqube->urlRepeatError = 'Server address already exists!';
|
||||
$lang->sonarqube->validError = 'SonarQube user authority authentication failed!';
|
||||
$lang->sonarqube->hostError = "Invalid SonarQube service address.";
|
||||
$lang->sonarqube->confirmDelete = 'Do you want to delete this SonarQube server?';
|
||||
$lang->sonarqube->confirmDeleteProject = 'Do you want to delete this SonarQube project?';
|
||||
|
||||
$lang->sonarqube->projectKey = 'Project Key';
|
||||
$lang->sonarqube->projectName = 'Project Name';
|
||||
$lang->sonarqube->projectlastAnalysis = 'Last analysis time';
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$lang->sonarqube = new stdclass;
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = '浏览SonarQube';
|
||||
$lang->sonarqube->search = '搜索';
|
||||
$lang->sonarqube->create = '添加SonarQube';
|
||||
$lang->sonarqube->edit = '编辑SonarQube';
|
||||
$lang->sonarqube->delete = '删除SonarQube';
|
||||
$lang->sonarqube->serverFail = '连接SonarQube服务器异常,请检查SonarQube服务器。';
|
||||
$lang->sonarqube->browseProject = "SonarQube项目列表";
|
||||
$lang->sonarqube->createProject = "创建SonarQube项目";
|
||||
$lang->sonarqube->deleteProject = "删除SonarQube项目";
|
||||
$lang->sonarqube->placeholderSearch = '请输入项目名称';
|
||||
$lang->sonarqube->execJob = "执行SonarQube任务";
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "服务器名称";
|
||||
$lang->sonarqube->url = '服务器地址';
|
||||
$lang->sonarqube->account = '用户名';
|
||||
$lang->sonarqube->password = '密码';
|
||||
$lang->sonarqube->token = 'Token';
|
||||
$lang->sonarqube->defaultProject = '默认项目';
|
||||
$lang->sonarqube->private = 'MD5验证';
|
||||
|
||||
$lang->sonarqube->createServer = '添加SonarQube服务器';
|
||||
$lang->sonarqube->editServer = '修改SonarQube服务器';
|
||||
$lang->sonarqube->desc = '描述';
|
||||
$lang->sonarqube->createSuccess = "创建成功";
|
||||
|
||||
$lang->sonarqube->placeholder = new stdclass;
|
||||
$lang->sonarqube->placeholder->name = '';
|
||||
$lang->sonarqube->placeholder->url = "请填写SonarQube Server首页的访问地址,如:https://sonarqube.zentao.net。";
|
||||
|
||||
$lang->sonarqube->nameRepeatError = "服务器名称已存在!";
|
||||
$lang->sonarqube->urlRepeatError = "服务器地址已存在!";
|
||||
$lang->sonarqube->validError = "SonarQube 用户权限认证失败!";
|
||||
$lang->sonarqube->hostError = "无效的SonarQube服务地址。";
|
||||
$lang->sonarqube->confirmDelete = '确认删除该SonarQube吗?';
|
||||
$lang->sonarqube->confirmDeleteProject = '确认删除该SonarQube项目吗?';
|
||||
|
||||
$lang->sonarqube->projectKey = '项目标识';
|
||||
$lang->sonarqube->projectName = '项目名称';
|
||||
$lang->sonarqube->projectlastAnalysis = '最后执行时间';
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package sonarqube
|
||||
* @version $Id: $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
|
||||
class sonarqubeModel extends model
|
||||
{
|
||||
/**
|
||||
* Get sonarqube api base url and header by id.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getApiBase($sonarqubeID)
|
||||
{
|
||||
$sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID);
|
||||
if(!$sonarqube) return array('', array());
|
||||
|
||||
$url = rtrim($sonarqube->url, '/') . '/api/%s';
|
||||
$header[] = 'Authorization: Basic ' . $sonarqube->token;
|
||||
|
||||
return array($url, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* check sonarqube valid
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $token
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function apiValidate($host, $token)
|
||||
{
|
||||
$url = rtrim($host, '/') . "/api/authentication/validate";
|
||||
$header = 'Authorization: Basic ' . $token;
|
||||
return json_decode(commonModel::http($url, null, array(), $header));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects of one sonarqube.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $keyword
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetProjects($sonarqubeID, $keyword = '')
|
||||
{
|
||||
list($apiRoot, $header) = $this->getApiBase($sonarqubeID);
|
||||
if(!$apiRoot) return array();
|
||||
|
||||
$url = sprintf($apiRoot, "projects/search");
|
||||
|
||||
$allResults = array();
|
||||
for($page = 1; true; $page++)
|
||||
{
|
||||
$result = json_decode(commonModel::http($url. "?p={$page}&ps=500" . ($keyword ? "&q={$keyword}" : ''), null, array(), $header));
|
||||
if(!isset($result->components)) break;
|
||||
if(!empty($result->components)) $allResults = array_merge($allResults, $result->components);
|
||||
if(count($result->components) < 500) break;
|
||||
}
|
||||
|
||||
return $allResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sonarqube project by api.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param int $projectKey
|
||||
* @access public
|
||||
* @return bool|object
|
||||
*/
|
||||
public function apiDeleteProject($sonarqubeID, $projectKey)
|
||||
{
|
||||
list($apiRoot, $header) = $this->getApiBase($sonarqubeID);
|
||||
if(!$apiRoot) return false;
|
||||
|
||||
$url = sprintf($apiRoot, "projects/delete?project=$projectKey");
|
||||
$result = json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'POST'), $header));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('sonarqube', 'create')) common::printLink('sonarqube', 'create', "", "<i class='icon icon-plus'></i> " . $lang->sonarqube->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($sonarqubeList)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(common::hasPriv('sonarqube', 'create')):?>
|
||||
<?php echo html::a($this->createLink('sonarqube', 'create'), "<i class='icon icon-plus'></i> " . $lang->sonarqube->create, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='sonarqubeList' class='table has-sort-head table-fixed'>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<th class='c-id text-center'><?php common::printOrderLink('id', $orderBy, $vars, $lang->sonarqube->id);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->sonarqube->name);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('url', $orderBy, $vars, $lang->sonarqube->url);?></th>
|
||||
<th class='c-actions-3'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($sonarqubeList as $id => $sonarqube): ?>
|
||||
<tr class='text'>
|
||||
<td class='text-center'><?php echo $id;?></td>
|
||||
<td class='text-c-name' title='<?php echo $sonarqube->name;?>'><?php echo $sonarqube->name;?></td>
|
||||
<td class='text' title='<?php echo $sonarqube->url;?>'><?php echo $sonarqube->url;?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
common::printLink('sonarqube', 'browseProject', "sonarqubeID=$id", "<i class='icon icon-list-box'></i> ", '',"title='{$lang->sonarqube->browseProject}' class='btn btn-primary'");
|
||||
common::printLink('sonarqube', 'edit', "sonarqubeID=$id", "<i class='icon icon-edit'></i> ", '',"title='{$lang->sonarqube->edit}' class='btn btn-primary'");
|
||||
if(common::hasPriv('sonarqube', 'delete')) echo html::a($this->createLink('sonarqube', 'delete', "sonarqubeID=$id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->sonarqube->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($sonarqubeList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Zeng <liugang@cnezsoft.com>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class='pull-left'>
|
||||
<?php echo html::a($this->createLink('sonarqube', 'browse'), "<i class='icon icon-back icon-sm'></i> " . $lang->goback, '', "class='btn btn-secondary'");?>
|
||||
</div>
|
||||
<div id="sidebarHeader">
|
||||
<div class="title"><?php echo $this->lang->sonarqube->common . ':' . $sonarqube->name; ?></div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-left">
|
||||
<div>
|
||||
<form id='sonarqubeProjectForm' method='post'>
|
||||
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->sonarqube->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
|
||||
<a id="projectSearch" class="btn btn-primary"><?php echo $lang->sonarqube->search?></a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right hide">
|
||||
<?php if(common::hasPriv('sonarqube', 'createProject')) common::printLink('sonarqube', 'createProject', "sonarqubeID=$sonarqubeID", "<i class='icon icon-plus'></i> " . $lang->sonarqube->createProject, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($sonarqubeProjectList)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(empty($keyword) and common::hasPriv('sonarqube', 'createProject')):?>
|
||||
<?php //echo html::a($this->createLink('sonarqube', 'createProject', "sonarqubeID=$sonarqubeID"), "<i class='icon icon-plus'></i> " . $lang->sonarqube->createProject, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='sonarqubeProjectList' class='table has-sort-head table-fixed'>
|
||||
<?php $vars = "sonarqubeID={$sonarqubeID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='c-key text-left'><?php common::printOrderLink('key', $orderBy, $vars, $lang->sonarqube->projectKey);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->sonarqube->projectName);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('lastAnalysisDate', $orderBy, $vars, $lang->sonarqube->projectlastAnalysis);?></th>
|
||||
<th class='c-actions-2'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($sonarqubeProjectList as $id => $sonarqubeProject): ?>
|
||||
<tr class='text'>
|
||||
<td class='text' title='<?php echo $sonarqubeProject->key;?>'><?php echo $sonarqubeProject->key;?></td>
|
||||
<td class='text-c-name' title='<?php echo $sonarqubeProject->name;?>'><?php echo $sonarqubeProject->name;?></td>
|
||||
<td class='text' title='<?php echo substr($sonarqubeProject->lastAnalysisDate, 0, 10);?>'><?php echo substr($sonarqubeProject->lastAnalysisDate, 0, 10);?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
/* Fix error when request type is PATH_INFO and the project key contains '-'.*/
|
||||
$projectKey = str_replace('-', '*', $sonarqubeProject->key);
|
||||
common::printLink('sonarqube', 'deleteProject', "sonarqubeID=$sonarqubeID&project=$projectKey", "<i class='icon icon-trash'></i> ", 'hiddenwin', "title='{$lang->sonarqube->deleteProject}' class='btn btn-primary'");
|
||||
if(isset($projectJobPairs[$sonarqubeProject->key]))
|
||||
{
|
||||
$jobID = $projectJobPairs[$sonarqubeProject->key];
|
||||
common::printIcon('sonarqube', 'execJob', "jobID=$jobID", '', 'list', 'sonarqube', 'hiddenwin');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($sonarqubeProjectList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* The create view file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Zeng <zenggang@cnezsoft.com>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->sonarqube->createServer;?></h2>
|
||||
</div>
|
||||
<form id='sonarqubeForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='c-name'><?php echo $lang->sonarqube->name;?></th>
|
||||
<td class='c-input'><?php echo html::input('name', '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->name}'");?></td>
|
||||
<td class="tips-git"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->url;?></th>
|
||||
<td><?php echo html::input('url', '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->url}'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->account;?></th>
|
||||
<td><?php echo html::input('account', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->password;?></th>
|
||||
<td><?php echo html::password('password', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* The edit view file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Zeng<zenggang@cnezsoft.com>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->sonarqube->editServer;?></h2>
|
||||
</div>
|
||||
<form id='sonarqubeForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class="c-name"><?php echo $lang->sonarqube->name;?></th>
|
||||
<td class="c-input"><?php echo html::input('name', isset($sonarqube->name) ? $sonarqube->name : '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->name}'");?></td>
|
||||
<td class="tips-git"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->url;?></th>
|
||||
<td><?php echo html::input('url', isset($sonarqube->url) ? $sonarqube->url : '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->url}'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->account;?></th>
|
||||
<td><?php echo html::input('account', isset($sonarqube->account) ? $sonarqube->account : '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->password;?></th>
|
||||
<td><?php echo html::password('password', isset($sonarqube->password) ? $sonarqube->password : '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -3,24 +3,24 @@ author: Zeng gang
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1
|
||||
range: 1-2
|
||||
- field: type
|
||||
range: gitlab
|
||||
range: gitlab,sonarqube
|
||||
- field: name
|
||||
range: gitlab服务器
|
||||
range: gitlab服务器,sonarqube服务器
|
||||
- field: url
|
||||
range: [http://192.168.1.161:51080]
|
||||
range: [http://192.168.1.161:51080],[http://192.168.1.161:59001]
|
||||
- field: account
|
||||
range: []
|
||||
range: [],[admin]
|
||||
- field: password
|
||||
range: []
|
||||
range: [],[UDJzc3cwcmQ=]
|
||||
- field: token
|
||||
range: x88fZokrp5hShia2jyBN
|
||||
range: x88fZokrp5hShia2jyBN,YWRtaW46UDJzc3cwcmQ=
|
||||
- field: private
|
||||
range: 08bcc98f75d7d40053dc80722bdc117b
|
||||
range: 08bcc98f75d7d40053dc80722bdc117b,228b25587479f2fc7570428e8bcbabdc
|
||||
- field: createdBy
|
||||
range: admin
|
||||
- field: createdDate
|
||||
range: [2021-12-09 11:23:35]
|
||||
range: [2021-12-09 11:23:35],[2022-01-12 08:47:37]
|
||||
- field: deleted
|
||||
range: 0
|
||||
|
||||
@@ -20,6 +20,6 @@ $builder->team = array('rows' => 400, 'extends' => array('team'));
|
||||
$builder->build = array('rows' => 8, 'extends' => array('build'));
|
||||
$builder->release = array('rows' => 8, 'extends' => array('release'));
|
||||
|
||||
$builder->pipeline = array('rows' => 1, 'extends' => array('pipeline'));
|
||||
$builder->pipeline = array('rows' => 2, 'extends' => array('pipeline'));
|
||||
$builder->repo = array('rows' => 1, 'extends' => array('repo'));
|
||||
$builder->mr = array('rows' => 1, 'extends' => array('mr'));
|
||||
|
||||
@@ -11,7 +11,7 @@ pid=1
|
||||
使用空的gitlabID、projectID、分支对象创建GitLab分支 >> return false
|
||||
使用空的gitlabID、projectID,正确的分支对象创建GitLab分支 >> return null
|
||||
使用正确的gitlabID、分支信息,错误的projectID创建分支 >> 404 Project Not Found
|
||||
使用正确的gitlabID,projectID,分支对象创建GitLab分支 >> test_branch17
|
||||
使用正确的gitlabID,projectID,分支对象创建GitLab分支 >> 1
|
||||
使用重复的分支信息创建分支 >> Branch already exists
|
||||
|
||||
*/
|
||||
@@ -36,5 +36,8 @@ $gitlabID = 1;
|
||||
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、分支信息,错误的projectID创建分支
|
||||
|
||||
$projectID = 1555;
|
||||
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('name') && e($branch->branch); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
|
||||
if(!empty($result->name) and $result->name == $branch->branch) $result = true;
|
||||
if(!empty($result->message) and $result->message == 'Branch already exists') $result = true;
|
||||
r($result) && p() && e(1); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('Branch already exists'); //使用重复的分支信息创建分支
|
||||
|
||||
@@ -40,6 +40,7 @@ if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //使用正确的gitlabID、保护分支信息,错误的projectID创建保护分支
|
||||
|
||||
$projectID = 966;
|
||||
$gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch->name);
|
||||
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('name') && e($branch->name); //通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支
|
||||
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('message') && e("Protected branch 'master' already exists"); //使用重复的保护分支信息创建保护分支
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ $tag = 'masters';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
r($result) && p('message') && e('404 Not found'); //使用错误的保护标签信息删除保护标签
|
||||
|
||||
$tag = '2021/12/30';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
$projectID = 1555;
|
||||
$tag = 'test_tag1';
|
||||
$result = $gitlab->apiDeleteTagPriv($gitlabID, $projectID, $tag);
|
||||
if(!$result or substr($result->message, 0, 2) == '20') $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签名称正确删除保护标签
|
||||
|
||||
@@ -8,11 +8,11 @@ title=测试 gitlabModel::apiGetBranches();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过gitlabID,projectID,获取GitLab分支列表 >> branch1
|
||||
通过gitlabID,projectID,获取GitLab分支数量 >> 3
|
||||
当前项目没有分支时,获取GitLab分支列表 >> 0
|
||||
通过gitlabID,projectID,获取GitLab分支列表 >> 1
|
||||
通过gitlabID,projectID,获取GitLab分支数量 >> 1
|
||||
当前项目没有分支时,获取GitLab分支列表 >> 0
|
||||
当gitlabID存在,projectID不存在时,获取GitLab分支列表 >> 404 Project Not Found
|
||||
当gitlabID,projectID都为0时,获取GitLab分支列表 >> return empty
|
||||
当gitlabID,projectID都为0时,获取GitLab分支列表 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
@@ -21,11 +21,11 @@ $gitlab = $tester->loadModel('gitlab');
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetBranches($gitlabID, $projectID);
|
||||
r($result) && p('0:name') && e('branch1'); //通过gitlabID,projectID,获取GitLab分支列表
|
||||
r(count($result)) && p() && e(3); //通过gitlabID,projectID,获取GitLab分支数量
|
||||
r(isset(array_shift($result)->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab分支列表
|
||||
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab分支数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1570;
|
||||
$projectID = 959;
|
||||
r(count($gitlab->apiGetBranches($gitlabID, $projectID))) && p() && e(0); //当前项目没有分支时,获取GitLab分支列表
|
||||
|
||||
$gitlabID = 1;
|
||||
|
||||
@@ -10,8 +10,8 @@ pid=1
|
||||
|
||||
使用空的gitlabID、projectID、保护分支获取保护分支 >> return false
|
||||
使用正确的gitlabID、保护分支信息,错误的projectID获取保护分支 >> 404 Project Not Found
|
||||
使用正确的gitlabID,projectID,保护分支获取保护分支 >> master
|
||||
使用错误的保护分支信息获取保护分支 >> 404 Not found
|
||||
使用正确的gitlabID,projectID,保护分支获取保护分支 >> master
|
||||
使用错误的保护分支信息获取保护分支 >> 404 Not found
|
||||
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ $branch = 'master';
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、保护分支信息,错误的projectID获取保护分支
|
||||
|
||||
$projectID = 1565;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetSingleBranchPriv($gitlabID, $projectID, $branch);
|
||||
r($result) && p('name') && e('master'); //通过gitlabID,projectID,分支名称正确获取保护分支
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ $gitlab = $tester->loadModel('gitlab');
|
||||
$gitlabID = 1;
|
||||
$projectID = 1552;
|
||||
$result = $gitlab->apiGetTagPrivs($gitlabID, $projectID);
|
||||
r(isset($result[0]->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护列表
|
||||
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护数量
|
||||
r(isset(array_shift($result)->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护列表
|
||||
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护数量
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 1570;
|
||||
|
||||
@@ -40,7 +40,13 @@ r($result) && p() && e('return false'); //使用正确的gitlabID、分支信息
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
|
||||
/* Delete branches with the same name. */
|
||||
$apiRoot = $gitlab->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/branches/{$_POST['branch']}");
|
||||
commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
|
||||
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
|
||||
|
||||
@@ -40,7 +40,12 @@ r($result) && p() && e('return false'); //使用正确的gitlabID、标签信息
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
|
||||
/* Delete tags with the same name. */
|
||||
$gitlab->apiDeleteTagPriv($gitlabID, $projectID, $_POST['tag_name']);
|
||||
$gitlab->apiDeleteTag($gitlabID, $projectID, $_POST['tag_name']);
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签对象正确创建GitLab标签
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ pid=0
|
||||
|
||||
使用空的RepoUrl数据创建 >> fail
|
||||
使用正确的RepoUrl,错误的分支数据创建mr请求 >> fail
|
||||
使用源分支和目标分支一样的数据创建mr请求 >> success
|
||||
使用源分支和目标分支一样的数据创建mr请求 >> success
|
||||
使用正确的数据创建mr请求 >> success
|
||||
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ r($result) && p() && e('fail'); //使用空的RepoUrl数据创建
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['data']['RepoUrl'] = 'http://192.168.1.161:51080/root/azalea723test.git';
|
||||
$_POST['data']['DiffMsg'] = '';
|
||||
$_POST['data']['DiffMsg'] = '';
|
||||
$_POST['data']['RepoSrcBranch'] = '';
|
||||
$_POST['data']['RepoDistBranch'] = '';
|
||||
$_POST['data']['MergeStatus'] = '1';
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiDeleteProject();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过不正确的sonarqubeID、projectKey,删除SonarQube项目 >> return false
|
||||
正确的sonarqubeID,空的projectKey,删除SonarQube项目 >> The 'project' parameter is missing
|
||||
正确的sonarqubeID,不存在的projectKey,删除SonarQube项目 >> Project 'no_project' not found
|
||||
正确的sonarqubeID、projectKey,删除SonarQube项目 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 0;
|
||||
$projectKey = '';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //通过不正确的sonarqubeID、projectKey,删除SonarQube项目
|
||||
|
||||
$sonarqubeID = 2;
|
||||
$projectKey = '';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
r($result->errors) && p('0:msg') && e("The 'project' parameter is missing"); //正确的sonarqubeID,空的projectKey,删除SonarQube项目
|
||||
|
||||
$projectKey = 'no_project';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
r($result->errors) && p('0:msg') && e("Project 'no_project' not found"); //正确的sonarqubeID,不存在的projectKey,删除SonarQube项目
|
||||
|
||||
$projectKey = 'new_project';
|
||||
list($apiRoot, $header) = $sonarqube->getApiBase($sonarqubeID);
|
||||
$url = sprintf($apiRoot, "projects/create?name=$projectKey&project=$projectKey");
|
||||
commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'POST'), $header);
|
||||
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
if($result === null) $result = 'return true';
|
||||
r($result) && p() && e("return true"); //正确的sonarqubeID、projectKey,删除SonarQube项目
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiGetProjects();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过sonarqubeID,获取SonarQube项目列表 >> 1
|
||||
通过sonarqubeID,获取SonarQube项目数量 >> 1
|
||||
通过sonarqubeID,关键字,搜索获取SonarQube项目 >> 1
|
||||
当sonarqubeID为0时,获取SonarQube项目列表 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 2;
|
||||
$result = $sonarqube->apiGetProjects($sonarqubeID);
|
||||
r(isset($result[0]->name)) && p() && e(1); //通过sonarqubeID,获取SonarQube项目列表
|
||||
r(count($result) > 0) && p() && e(1); //通过sonarqubeID,获取SonarQube项目数量
|
||||
|
||||
$keyword = '02';
|
||||
$result = $sonarqube->apiGetProjects($sonarqubeID, $keyword);
|
||||
r(strpos($result[0]->name, '02') !== false) && p() && e(1); //通过sonarqubeID,关键字,搜索获取SonarQube项目
|
||||
|
||||
$sonarqubeID = 0;
|
||||
$result = $sonarqube->apiGetProjects($sonarqubeID);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当sonarqubeID为0时,获取SonarQube项目列表
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiValidate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过host,token检验api权限 >> 1
|
||||
通过正确的host,错误的token获取api权限 >> return false
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 2;
|
||||
$sonarqubeServer = $sonarqube->getByID($sonarqubeID);
|
||||
$result = $sonarqube->apiValidate($sonarqubeServer->url, $sonarqubeServer->token);
|
||||
r($result) && p('valid') && e(1); //通过host,token检验api权限
|
||||
|
||||
$result = $sonarqube->apiValidate($sonarqubeServer->url, $sonarqubeServer->token . 'a');
|
||||
if($result->valid == false) $result = 'return false';
|
||||
r($result) && p('') && e(''); //通过正确的host,错误的token获取api权限
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::getApiBase();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过sonarqubeID,获取SonarQube url和header >> http://192.168.1.161:59001/api/%s
|
||||
当sonarqubeID为0时,获取SonarQube url和header >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 2;
|
||||
list($apiRoot, $header) = $sonarqube->getApiBase($sonarqubeID);
|
||||
r($apiRoot) && p() && e('http://192.168.1.161:59001/api/%s'); //通过sonarqubeID,获取SonarQube url和header
|
||||
|
||||
$sonarqubeID = 0;
|
||||
list($apiRoot, $header) = $sonarqube->getApiBase($sonarqubeID);
|
||||
if(empty($apiRoot)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当sonarqubeID为0时,获取SonarQube url和header
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::getByID();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过id获取sonarqube服务器 >> sonarqube服务器
|
||||
通过空的id获取sonarqube服务器 >> return empty
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 2;
|
||||
$sonarqubeServer = $sonarqube->getByID($sonarqubeID);
|
||||
r($sonarqubeServer) && p('name') && e('sonarqube服务器'); //通过id获取sonarqube服务器
|
||||
|
||||
$sonarqubeID = 0;
|
||||
$sonarqubeServer = $sonarqube->getByID($sonarqubeID);
|
||||
if(empty($sonarqubeServer)) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //通过空的id获取sonarqube服务器
|
||||
Reference in New Issue
Block a user