fix: use unified server ID for deployment commands in rebuildApplication

- Updated the rebuildApplication function to utilize a consistent server ID by incorporating buildServerId where available.
- Refactored deployment command execution to ensure compatibility with the new server ID logic, enhancing deployment reliability.
This commit is contained in:
Mauricio Siu
2025-11-29 23:25:01 -06:00
parent 8cff84ef54
commit 035f8835cf
+5 -4
View File
@@ -287,6 +287,7 @@ export const rebuildApplication = async ({
descriptionLog: string; descriptionLog: string;
}) => { }) => {
const application = await findApplicationById(applicationId); const application = await findApplicationById(applicationId);
const serverId = application.buildServerId || application.serverId;
const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`; const buildLink = `${await getDokployUrl()}/dashboard/project/${application.environment.projectId}/environment/${application.environmentId}/services/application/${application.applicationId}?tab=deployments`;
const deployment = await createDeployment({ const deployment = await createDeployment({
@@ -300,8 +301,8 @@ export const rebuildApplication = async ({
// Check case for docker only // Check case for docker only
command += getBuildCommand(application); command += getBuildCommand(application);
const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`; const commandWithLog = `(${command}) >> ${deployment.logPath} 2>&1`;
if (application.serverId) { if (serverId) {
await execAsyncRemote(application.serverId, commandWithLog); await execAsyncRemote(serverId, commandWithLog);
} else { } else {
await execAsync(commandWithLog); await execAsync(commandWithLog);
} }
@@ -340,8 +341,8 @@ export const rebuildApplication = async ({
} }
command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`; command += `echo "\nError occurred ❌, check the logs for details." >> ${deployment.logPath};`;
if (application.serverId) { if (serverId) {
await execAsyncRemote(application.serverId, command); await execAsyncRemote(serverId, command);
} else { } else {
await execAsync(command); await execAsync(command);
} }