* [feedback#7498] adjust job status sync logic.

This commit is contained in:
caoyanyi
2024-11-01 14:30:59 +08:00
committed by 谢杞钰
parent 54c2ce69e0
commit 00a20cb98d
2 changed files with 24 additions and 4 deletions
+23 -3
View File
@@ -122,12 +122,32 @@ class ciModel extends model
else
{
$queueInfo = json_decode($response);
$buildInfo = null;
if(!empty($queueInfo->executable))
{
$buildUrl = $queueInfo->executable->url . 'api/json?pretty=true';
$response = common::http($buildUrl, '', array(CURLOPT_USERPWD => $userPWD));
$buildInfo = json_decode($response);
}
elseif(stripos($response, 'not found') !== false)
{
$job = strpos($compile->pipeline, '/job/') !== false ? $compile->pipeline : '/job/' . $compile->pipeline;
$buildUrl = "{$compile->url}{$job}/api/json?depth=1";
$response = json_decode(common::http($buildUrl, '', array(CURLOPT_USERPWD => $userPWD)));
if($response)
{
foreach($response->builds as $build)
{
if($build->queueId == $compile->queue)
{
$buildInfo = $build;
break;
}
}
}
}
if($buildInfo)
{
if(!empty($buildInfo->building))
{
$this->updateBuildStatus($compile, 'building');
@@ -160,8 +180,8 @@ class ciModel extends model
*/
public function syncCompileStatus(object $compile, int $MRID = 0): bool
{
/* Max retry times is: 3. */
if($compile->times >= 3)
/* Max retry times is: 5. */
if($compile->times >= 5)
{
$this->updateBuildStatus($compile, 'failure');
+1 -1
View File
@@ -102,7 +102,7 @@ class compile extends control
$build = $this->compile->getByID($buildID);
$job = $this->loadModel('job')->getByID($build->job);
if(empty($build->logs) and !in_array($build->status, array('created', 'pending'))) $build->logs = $this->compile->getLogs($job, $build);
if(!in_array($build->status, array('created', 'pending'))) $build->logs = $this->compile->getLogs($job, $build);
$logs = $build->logs ? str_replace(array("\r\n", "\n"), "<br />", $build->logs) : '';
$this->view->logs = $logs;