fix the bug about jenkins build request and status checking

This commit is contained in:
aaronchen2k
2020-02-04 14:30:41 +08:00
parent dbd4f4a960
commit 9ecf575c3c
+19 -19
View File
@@ -253,24 +253,6 @@ class ciModel extends model
$this->dao->insert(TABLE_CI_BUILD)->data($build)->exec();
}
/**
* Update ci build status.
*
* @param object $build
* @param string $status
* @access public
* @return bool
*/
public function updateBuildStatus($build, $status)
{
$this->dao->update(TABLE_CI_BUILD)->set('status')->eq($status)->where('id')->eq($build->id)->exec();
$this->dao->update(TABLE_CI_JOB)
->set('lastExec')->eq(helper::now())
->set('lastStatus')->eq($status)
->where('id')->eq($build->cijob)->exec();
}
/**
* Send a request to jenkins to check build status.
*
@@ -299,7 +281,7 @@ class ciModel extends model
$queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $po->queueItem);
$response = common::http($queueUrl);
if (strripos($response,"404") > -1) { // queue已过期
if (strripos($response,"404") > -1) { // queue expired, use another api
$infoUrl = sprintf('%s/job/%s/%s/api/json', $jenkinsServer, $po->jenkinsJob, $po->queueItem);
$response = common::http($infoUrl);
$buildInfo = json_decode($response);
@@ -340,6 +322,24 @@ class ciModel extends model
}
}
/**
* Update ci build status.
*
* @param object $build
* @param string $status
* @access public
* @return bool
*/
public function updateBuildStatus($build, $status)
{
$this->dao->update(TABLE_CI_BUILD)->set('status')->eq($status)->where('id')->eq($build->id)->exec();
$this->dao->update(TABLE_CI_JOB)
->set('lastExec')->eq(helper::now())
->set('lastStatus')->eq($status)
->where('id')->eq($build->cijob)->exec();
}
/**
* @param $url
* @return false|mixed|string