From d9449bb507119aed068fb527299b9c2b05b737a9 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 10 Feb 2022 07:56:14 +0000 Subject: [PATCH] * Modify job result message. --- module/ci/model.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/module/ci/model.php b/module/ci/model.php index 7ca7e64b25..2c3f7397e0 100644 --- a/module/ci/model.php +++ b/module/ci/model.php @@ -61,10 +61,15 @@ class ciModel extends model */ public function syncCompileStatus($compile, $notCompileMR) { + $MRID = array_search($compile->job, $notCompileMR); + /* Max retry times is: 3. */ if($compile->times >= 3) { $this->updateBuildStatus($compile, 'failure'); + + /* Added merge request result push to xuanxuan. */ + if($MRID) $this->loadModel('message')->send('mr', $MRID, 'compilefail', 0); return false; } @@ -76,6 +81,7 @@ class ciModel extends model $queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queue); $response = common::http($queueUrl, '', array(CURLOPT_USERPWD => $userPWD)); + $result = ''; if($compile->engine != 'gitlab') $this->dao->update(TABLE_COMPILE)->set('times = times + 1')->where('id')->eq($compile->id)->exec(); if(strripos($response, "404") > -1) @@ -123,11 +129,9 @@ class ciModel extends model } } - /* Added merge request result push to xuanxuan. */ - $MRID = array_search($compile->job, $notCompileMR); - if($MRID) + if($MRID && in_array($result, array('success', 'failure'))) { - $actionType = $compile->status == 'success' ? 'compilepass' : 'compilefail'; + $actionType = $result == 'success' ? 'compilepass' : 'compilefail'; $this->loadModel('message')->send('mr', $MRID, $actionType, 0); } }