* Add tips when gitlab has not pipelines.
This commit is contained in:
@@ -2879,4 +2879,21 @@ class gitlabModel extends model
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pipeline with api.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param string $branch
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function apiGetPipeline($gitlabID, $projectID, $branch)
|
||||
{
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/$projectID/pipelines") . "&ref=$branch";
|
||||
a($url);
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +181,15 @@ class jobModel extends model
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
|
||||
$project = zget($repo, 'project');
|
||||
if(!empty($repo))
|
||||
{
|
||||
$pipeline = $this->loadModel('gitlab')->apiGetPipeline($repo->serviceHost, $repo->serviceProject, $this->post->reference);
|
||||
if(!is_array($pipeline) or empty($pipeline))
|
||||
{
|
||||
dao::$errors['repo'] = $this->lang->job->engineTips->error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$job->server = (int)zget($repo, 'serviceHost', 0);
|
||||
$job->pipeline = json_encode(array('project' => $project, 'reference' => $this->post->reference));
|
||||
@@ -298,6 +307,15 @@ class jobModel extends model
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getRepoByID($job->gitlabRepo);
|
||||
$project = zget($repo, 'project');
|
||||
if(!empty($repo))
|
||||
{
|
||||
$pipeline = $this->loadModel('gitlab')->apiGetPipeline($repo->serviceHost, $repo->serviceProject, $this->post->reference);
|
||||
if(!is_array($pipeline) or empty($pipeline))
|
||||
{
|
||||
dao::$errors['repo'] = $this->lang->job->engineTips->error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$job->repo = $job->gitlabRepo;
|
||||
$job->server = (int)zget($repo, 'serviceHost', 0);
|
||||
|
||||
Reference in New Issue
Block a user