diff --git a/module/ci/model.php b/module/ci/model.php index c66909f513..56c7ce1935 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -137,13 +137,34 @@ class ciModel extends model foreach($jobs as $job) { if(empty($job->duration) or $job->duration == '') $job->duration = '-'; - $log .= "Name: $job->name, Stage: $job->stage, Status: $job->status, Duration: $job->duration \r\n Web URL: $job->web_url \r\n"; - $log .= $this->loadModel('gitlab')->apiGetJobLog($compile->server, $compile->pipeline, $job->id) . "\r\n\r\n\r\n"; + $log .= ">>> Name: $job->name, Stage: $job->stage, Status: $job->status, Duration: $job->duration \r\n "; + $log .= "Web URL: web_url\" target='_blank'>$job->web_url \r\n"; + $log .= $this->transformAnsiToHtml($this->loadModel('gitlab')->apiGetJobLog($compile->server, $compile->pipeline, $job->id)); } $this->dao->update(TABLE_COMPILE)->set('status')->eq($pipeline->status)->set('updateDate')->eq($now)->set('logs')->eq($log)->where('id')->eq($compile->id)->exec(); $this->dao->update(TABLE_JOB)->set('lastExec')->eq($now)->set('lastStatus')->eq($pipeline->status)->where('id')->eq($compile->job)->exec(); } + /** + * Transform ansi text to html. + * + * @param string $text + * @access public + * @return string + */ + public function transformAnsiToHtml($text) + { + $text = preg_replace("/\x1B\[31;40m/", '', $text); + $text = preg_replace("/\x1B\[32;1m/", '', $text); + $text = preg_replace("/\x1B\[32;1m/", '', $text); + $text = preg_replace("/\x1B\[36;1m/", '', $text); + $text = preg_replace("/\x1B\[0;33m/", '', $text); + $text = preg_replace("/\x1B\[1m/", '', $text); + $text = preg_replace("/\x1B\[0;m/", '
', $text); + $text = preg_replace("/\x1B\[0K/", '
', $text); + return $text; + } + /** * Update ci build status. *