Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: post deployment command could fail, but won't make the deployment fail anymore feat: better error for post deployment command

Andras Bacsai370c9b63cf53
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 8a949da5a4..6517aae0ab 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -289,7 +289,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
private function post_deployment()
{
-
if ($this->server->isProxyShouldRun()) {
GetContainersStatus::dispatch($this->server);
// dispatch(new ContainerStatusJob($this->server));
@@ -1992,7 +1991,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
if ($containers->count() == 0) {
return;
}
- $this->application_deployment_queue->addLogEntry("Executing pre-deployment command (see debug log for output).");
+ $this->application_deployment_queue->addLogEntry("Executing pre-deployment command (see debug log for output/errors).");
foreach ($containers as $container) {
$containerName = data_get($container, 'Names');
@@ -2015,6 +2014,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
if (empty($this->application->post_deployment_command)) {
return;
}
+ $this->application_deployment_queue->addLogEntry("----------------------------------------");
$this->application_deployment_queue->addLogEntry("Executing post-deployment command (see debug log for output).");
$containers = getCurrentApplicationContainerStatus($this->server, $this->application->id, $this->pull_request_id);
@@ -2023,11 +2023,20 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
if ($containers->count() == 1 || str_starts_with($containerName, $this->application->post_deployment_command_container . '-' . $this->application->uuid)) {
$cmd = "sh -c '" . str_replace("'", "'\''", $this->application->post_deployment_command) . "'";
$exec = "docker exec {$containerName} {$cmd}";
- $this->execute_remote_command(
- [
- 'command' => $exec, 'hidden' => true
- ],
- );
+ try {
+ $this->execute_remote_command(
+ [
+ 'command' => $exec, 'hidden' => true, 'save' => 'post-deployment-command-output'
+ ],
+ );
+ } catch (Exception $e) {
+ $post_deployment_command_output = $this->saved_outputs->get('post-deployment-command-output');
+ if ($post_deployment_command_output) {
+ $this->application_deployment_queue->addLogEntry("Post-deployment command failed.");
+ $this->application_deployment_queue->addLogEntry($post_deployment_command_output, 'stderr');
+ }
+ }
+
return;
}
}