From 6fe756fb143d80d9337654c64371516aaf0c6b5b Mon Sep 17 00:00:00 2001 From: Guan Xiying Date: Thu, 29 Jul 2021 16:26:20 +0800 Subject: [PATCH] * Adjust param of ciModel::checkCompileStatus function. --- module/ci/control.php | 16 ++++++++-------- module/ci/model.php | 13 ++++--------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/module/ci/control.php b/module/ci/control.php index 0f7f12e1be..88358edef3 100644 --- a/module/ci/control.php +++ b/module/ci/control.php @@ -61,21 +61,21 @@ class ci extends control /** * Send a request to jenkins or gitlab to check build status. * - * @param string $gitlabOnly + * @param int $compileID * @access public - * @return string + * @return void */ - public function checkCompileStatus($gitlabOnly = 'no') + public function checkCompileStatus($compileID = 0) { - $this->ci->checkCompileStatus($gitlabOnly); + $this->ci->checkCompileStatus($compileID); + if(dao::isError()) { echo json_encode(dao::getError()); + return true; } - else - { - echo $gitlabOnly == 'yes' ? 'gitlab success' : 'success'; - } + + echo 'success'; } /** diff --git a/module/ci/model.php b/module/ci/model.php index 0f0beeda54..0ce1aa8f8f 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -23,10 +23,11 @@ class ciModel extends model /** * Send a request to jenkins to check build status. * + * @param int $compileID * @access public * @return void */ - public function checkCompileStatus($gitlabOnly = 'no') + public function checkCompileStatus($compileID = 0) { $compiles = $this->dao->select('compile.*, job.engine,job.pipeline, pipeline.name as jenkinsName,job.server,pipeline.url,pipeline.account,pipeline.token,pipeline.password') ->from(TABLE_COMPILE)->alias('compile') @@ -36,17 +37,11 @@ class ciModel extends model ->andWhere('compile.status')->ne('failure') ->andWhere('compile.status')->ne('create_fail') ->andWhere('compile.status')->ne('timeout') + ->beginIf($compileID)->andWhere('compile.id')->eq($compileID)->fi() ->andWhere('compile.createdDate')->gt(date(DT_DATETIME1, strtotime("-1 day"))) ->fetchAll(); - if($gitlabOnly == 'yes') - { - foreach($compiles as $compile) if($compile->engine == 'gitlab') $this->syncCompileStatus($compile); - } - elseif($gitlabOnly == 'no') - { - foreach($compiles as $compile) $this->syncCompileStatus($compile); - } + foreach($compiles as $compile) $this->syncCompileStatus($compile); } /**