* [bug#59069] adjust job sync date.

This commit is contained in:
caoyanyi
2025-01-09 09:22:45 +08:00
committed by 田淑杰
parent e9b405f3bf
commit 1506937355
2 changed files with 22 additions and 10 deletions
+15 -8
View File
@@ -65,8 +65,9 @@ class compileTao extends compileModel
if($buildType == 'gitlab' && empty($build->id)) return false;
$data = new stdclass();
$data->name = $name;
$data->job = $jobID;
$data->name = $name;
$data->job = $jobID;
$data->createdBy = 'system';
if($buildType == 'jenkins')
{
@@ -75,19 +76,25 @@ class compileTao extends compileModel
if($build->result == 'FAILURE') $data->status = 'failure';
$data->createdDate = date('Y-m-d H:i:s', (int)($build->timestamp / 1000));
$data->updateDate = $data->createdDate;
}
else
{
$data->queue = !empty($build->number) ? $build->number : $build->id;
$data->status = isset($this->lang->compile->statusList[$build->status]) ? $build->status : 'failure';
$date = isset($build->created_at) ? strtotime($build->created_at) : time();
if(isset($build->created)) $date = $build->created;
$data->createdDate = date('Y-m-d H:i:s', $date);
}
$createdDate = isset($build->created_at) ? strtotime($build->created_at) : time();
if(isset($build->created)) $createdDate = $build->created;
$data->createdDate = date('Y-m-d H:i:s', $createdDate);
$data->createdBy = $this->app->user ? $this->app->user->account : 'guest';
$data->updateDate = $data->createdDate ?? date('Y-m-d H:i:s');
$updatedDate = isset($build->updated_at) ? strtotime($build->updated_at) : $createdDate;
if(isset($build->updated))
{
if(strlen($build->updated) > 10) $updatedDate = intval($build->updated / 1000);
$updatedDate = $build->updated;
}
$data->updateDate = date('Y-m-d H:i:s', $updatedDate);
}
$this->dao->insert(TABLE_COMPILE)->data($data)->exec();
$this->dao->update(TABLE_JOB)->set('lastExec')->eq($data->createdDate)->set('lastStatus')->eq($data->status)->where('id')->eq($jobID)->exec();
+7 -2
View File
@@ -565,19 +565,24 @@ class jobModel extends model
$pipelines = $this->loadModel(strtolower($repo->SCM))->apiGetPipeline((int)$repo->serviceHost, (int)$repo->serviceProject, '');
if(!is_array($pipelines) or empty($pipelines)) return false;
$job = new stdclass;
$job = new stdclass();
$job->name = $repo->name;
$job->repo = $repoID;
$job->product = is_numeric($repo->product) ? $repo->product : explode(',', $repo->product)[0];
$job->engine = strtolower($repo->SCM);
$job->server = $repo->serviceHost;
$job->createdBy = $this->app->user->account;
$job->createdBy = 'system';
$addedPipelines = array();
foreach($pipelines as $pipeline)
{
if(!empty($pipeline->disabled)) continue;
$createdDate = helper::now();
if(isset($pipeline->created_at)) $createdDate = date('Y-m-d H:i:s', strtotime($pipeline->created_at));
$job->createdDate = $createdDate;
if(isset($pipeline->updated_at)) $job->editedDate = date('Y-m-d H:i:s', strtotime($pipeline->updated_at));
$pipelineMeta = array('project' => $repo->serviceProject, 'reference' => isset($pipeline->ref) ? $pipeline->ref : $pipeline->default_branch);
$job->pipeline = json_encode($pipelineMeta);