diff --git a/module/gitlab/model.php b/module/gitlab/model.php index f6157070c4..41681cdb20 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -252,6 +252,20 @@ class gitlabModel extends model ->fetch('openID'); } + /** + * Get gitlab project name of one gitlab project. + * + * @param int $jobID + * @access public + * @return string|false + */ + public function getObjectNameForJob($gitlabID, $projectID) + { + $project = $this->apiGetSingleProject($gitlabID, $projectID); + if(isset($project->name)) return $project->name; + return false; + } + /** * Create a gitlab. * diff --git a/module/job/model.php b/module/job/model.php index f6fd2b098c..3b4a0c34fc 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -404,22 +404,4 @@ class jobModel extends model return $compile->status; } - - /** - * Get gitlab project name by jobID. - * - * @param int $jobID - * @access public - * @return string|false - */ - public function getGitlabProjectName($jobID) - { - $job = $this->getByID($jobID); - if(strtolower($job->engine) != 'gitlab') return false; - $gitlabID = $job->server; - $projectID = $job->pipeline; - $project = $this->loadModel('gitlab')->apiGetSingleProject($gitlabID, $projectID); - if(isset($project->name)) return $project->name; - return false; - } } diff --git a/module/job/view/browse.html.php b/module/job/view/browse.html.php index bce333a1a2..f44dc8a7ba 100644 --- a/module/job/view/browse.html.php +++ b/module/job/view/browse.html.php @@ -46,7 +46,7 @@ repoName; ?> job->engineList, $job->engine);?> job->frameList, $job->frame);?> - engine) == 'gitlab') $job->pipeline = $this->job->getGitlabProjectName($job->id);?> + engine) == 'gitlab') $job->pipeline = $this->loadModel('gitlab')->getObjectNameForJob($job->server, $job->pipeline);?> pipeline) . '@' . $job->jenkinsName;?> job->getTriggerConfig($job);?> diff --git a/module/job/view/view.html.php b/module/job/view/view.html.php index ff1f89a943..cab49151d0 100644 --- a/module/job/view/view.html.php +++ b/module/job/view/view.html.php @@ -55,7 +55,7 @@ job->server;?> - engine) == 'gitlab') $job->pipeline = $this->job->getGitlabProjectName($job->id);?> + engine) == 'gitlab') $job->pipeline = $this->loadModel('gitlab')->getObjectNameForJob($job->server, $job->pipeline);?> pipeline) . '@' . $jenkins->name;?>