* Fix bug #18448.
This commit is contained in:
@@ -121,7 +121,7 @@ class job extends control
|
||||
$this->view->products = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->projectID);
|
||||
|
||||
$this->view->jenkinsServerList = array('' => '') + $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('' => '') + $this->loadModel('sonarqube')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs();
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -198,9 +198,9 @@ class job extends control
|
||||
$this->view->repoTypes = $repoTypes;
|
||||
$this->view->repoType = zget($repoTypes, $job->repo, 'Git');
|
||||
$this->view->job = $job;
|
||||
$this->view->products = array(0 => '') + $products;
|
||||
$this->view->products = array('') + $products;
|
||||
$this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('' => '') + $this->loadModel('sonarqube')->getPairs();
|
||||
$this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs();
|
||||
$this->view->pipelines = $this->jenkins->getTasks($job->server);
|
||||
|
||||
$this->display();
|
||||
|
||||
@@ -57,6 +57,7 @@ $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->buildTypeList['build'] = 'Only Build';
|
||||
|
||||
@@ -57,6 +57,7 @@ $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->buildTypeList['build'] = '仅构建';
|
||||
|
||||
@@ -194,12 +194,23 @@ class jobModel extends model
|
||||
$sonarqubeJob = $this->getSonarqubeByRepo(array($job->repo));
|
||||
if(!empty($sonarqubeJob))
|
||||
{
|
||||
$message = sprintf($this->lang->job->repoExists, $repo[$repoID]->id . '-' . $repo[$repoID]->name);
|
||||
$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 = '';
|
||||
@@ -300,12 +311,23 @@ class jobModel extends model
|
||||
$sonarqubeJob = $this->getSonarqubeByRepo(array($job->repo), $id);
|
||||
if(!empty($sonarqubeJob))
|
||||
{
|
||||
$message = sprintf($this->lang->job->repoExists, $repo[$repoID]->id . '-' . $repo[$repoID]->name);
|
||||
$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 = '';
|
||||
@@ -599,16 +621,17 @@ class jobModel extends model
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param array $projectKeys
|
||||
* @param bool $emptyShowAll
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array())
|
||||
public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false)
|
||||
{
|
||||
return $this->dao->select('projectKey,id')->from(TABLE_JOB)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('frame')->eq('sonarqube')
|
||||
->andWhere('sonarqubeServer')->eq($sonarqubeID)
|
||||
->andWhere('projectKey')->in($projectKeys)
|
||||
->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi()
|
||||
->fetchPairs();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user