better way to find last push
This commit is contained in:
parent
a1015c2db7
commit
7ad311892c
@ -43,17 +43,18 @@ if (COCKPIT_ADMIN && !COCKPIT_API_REQUEST) {
|
|||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
$unfiltered_deploys = json_decode($unfiltered_deploys);
|
$unfiltered_deploys = json_decode($unfiltered_deploys);
|
||||||
$build = $settings['build'];
|
$build = $settings['build'];
|
||||||
|
$last_push = '';
|
||||||
|
$last_promote = '';
|
||||||
if ($unfiltered_deploys && is_array($unfiltered_deploys)) {
|
if ($unfiltered_deploys && is_array($unfiltered_deploys)) {
|
||||||
foreach($unfiltered_deploys as $deploy) {
|
foreach($unfiltered_deploys as $deploy) {
|
||||||
if ($deploy->{target} == $branch && ($deploy->event == 'push' || ($deploy->event == 'promote' && $deploy->deploy_to == $settings['target']))) {
|
if ($deploy->{target} == $branch && ($deploy->event == 'push' || ($deploy->event == 'promote' && $deploy->deploy_to == $settings['target']))) {
|
||||||
// find latest successful build
|
// find latest successful build
|
||||||
if (!$build) {
|
if (!$last_push && $deploy->event == 'push' && $deploy->status == 'success') {
|
||||||
if ($deploy->event == 'push' && $deploy->status == 'success') {
|
$last_push = $deploy->number;
|
||||||
$build = $deploy->number;
|
} elseif (!$last_promote) {
|
||||||
} else {
|
$last_promote = $deploy->parent;
|
||||||
$build = $deploy->parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit--;
|
$limit--;
|
||||||
if ($limit>0) {
|
if ($limit>0) {
|
||||||
$deploys[] = $deploy;
|
$deploys[] = $deploy;
|
||||||
@ -62,6 +63,10 @@ if (COCKPIT_ADMIN && !COCKPIT_API_REQUEST) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$build) {
|
||||||
|
$build = $last_push ? $last_push : $last_promote;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse dates and check if any deploy is on building status.
|
// Parse dates and check if any deploy is on building status.
|
||||||
$building = false;
|
$building = false;
|
||||||
foreach ($deploys as $idx => $deploy) {
|
foreach ($deploys as $idx => $deploy) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user