diff --git a/app/config/collections.php b/app/config/collections.php index 56883fc297..befcc5e06a 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2038,6 +2038,28 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => 'endTime', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'duration', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'deploymentId', 'type' => Database::VAR_STRING, @@ -2104,28 +2126,6 @@ $collections = [ 'array' => false, 'filters' => [], ], - [ - '$id' => 'endTime', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'duration', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], [ '$id' => 'sourceType', 'type' => Database::VAR_STRING, diff --git a/app/executor.php b/app/executor.php index cdc44cb569..f0ca068a23 100644 --- a/app/executor.php +++ b/app/executor.php @@ -730,7 +730,25 @@ function runBuildStage(string $buildId, string $projectID): Document throw new Exception('Code is not readable: ' . $build->getAttribute('source', '')); } - $vars = $build->getAttribute('vars', []); + $deployment = $database->getDocument('deployments', $build->getAttribute('deploymentId', '')); + $resourceId = $deployment->getAttribute('resourceId', ''); + $resourceType = $deployment->getAttribute('resourceType', ''); + + if (empty($resourceId)) { + throw new Exception('Invalid resource ID on build ' . $build->getId()); + } + + if (empty($resourceType)) { + throw new Exception('Invalid resource type on build' . $build->getId()); + } + + $resource = $database->getDocument($resourceType, $resourceId); + + if ($resource->isEmpty()) { + throw new Exception('Resource not found on build ' . $build->getId()); + } + + $vars = $resource->getAttribute('vars', []); $orchestration ->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', 0))