loadModel('job')->getByID($jobID); $status = $job->lastStatus; if($status and $status != 'success' and $status != 'create_fail') { $compile = $this->loadModel('compile')->getLastResult($jobID); if($compile) { $pipeline = $this->gitlabpipeline->apiGetPiplineByID($job->server, $job->pipeline, $compile->queue); $this->dao->update(TABLE_COMPILE)->set('status')->eq($pipeline->status)->set('updateDate')->eq($now)->where('id')->eq($compile->id)->exec(); $this->dao->update(TABLE_JOB)->set('lastExec')->eq($now)->set('lastStatus')->eq($pipeline->status)->where('id')->eq($jobID)->exec(); } echo js::alert($this->lang->gitlabpipeline->execError); die(js::reload('parent')); } $pipeline = $this->gitlabpipeline->apiCreatePipeline($job->server, $job->pipeline, array('ref' => 'master')); $status = isset($pipeline->id) ? 'created' : 'create_fail'; $this->dao->update(TABLE_JOB)->set('lastExec')->eq($now)->set('lastStatus')->eq($status)->where('id')->eq($jobID)->exec(); if(!isset($pipeline->id)) return false; $build = new stdclass; $build->job = $jobID; $build->name = $job->name; $build->queue = $pipeline->id; // use `queue` to save gitlab project pipeline id. $build->status = $pipeline->status; $build->createdBy = $this->app->user->account; $build->createdDate = $now; $this->dao->insert(TABLE_COMPILE)->data($build)->exec(); echo js::alert(sprintf($this->lang->gitlabpipeline->sendExec, $pipeline->status)); die(js::reload('parent')); } }