fix(cli): artifact-deploy commands exit 1 when any site failed
site deploy-artifacts and deploy artifacts rendered the per-site summary and always exited 0, so a script could not tell a failed site (unreachable, missing or unreadable secret, partial apply) from a clean deploy. Both now route through the failureCount rule deploy site already used.
This commit is contained in:
@@ -89,7 +89,14 @@ public static class DeployCommands
|
||||
/// </summary>
|
||||
internal static readonly TimeSpan BulkDeployTimeout = Timeout.InfiniteTimeSpan;
|
||||
|
||||
internal static int HandleSiteDeploymentResponse(string json, string format)
|
||||
/// <summary>
|
||||
/// Renders a deployment summary and turns its <c>failureCount</c> into the exit code:
|
||||
/// 0 when every site/instance succeeded, 1 when any failed. Shared by <c>deploy site</c>
|
||||
/// and both artifact-deploy commands (<c>deploy artifacts</c>, <c>site deploy-artifacts</c>),
|
||||
/// whose summaries all carry <c>failureCount</c> — a per-site failure is a successful HTTP
|
||||
/// call, so without this the process exited 0 and scripts could not detect it.
|
||||
/// </summary>
|
||||
internal static int HandleSiteDeploymentResponse(string json, string format, string summaryName = "site deployment")
|
||||
{
|
||||
CommandHelpers.HandleResponse(new ManagementResponse(200, json, null, null), format);
|
||||
try
|
||||
@@ -100,7 +107,7 @@ public static class DeployCommands
|
||||
return count == 0 ? 0 : 1;
|
||||
}
|
||||
catch (JsonException) { }
|
||||
OutputFormatter.WriteError("The server returned an invalid site deployment summary.", "INVALID_RESPONSE");
|
||||
OutputFormatter.WriteError($"The server returned an invalid {summaryName} summary.", "INVALID_RESPONSE");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -113,7 +120,9 @@ public static class DeployCommands
|
||||
{
|
||||
var siteId = result.GetValue(siteIdOption);
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new MgmtDeployArtifactsCommand(siteId));
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new MgmtDeployArtifactsCommand(siteId),
|
||||
onSuccess: json => HandleSiteDeploymentResponse(
|
||||
json, CommandHelpers.ResolveFormat(result, formatOption, CliConfig.Load()), "artifact deployment"));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -222,8 +222,11 @@ public static class SiteCommands
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
var siteId = result.GetValue(siteIdOption);
|
||||
// Exit 1 when any site failed (see DeployCommands.HandleSiteDeploymentResponse).
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new MgmtDeployArtifactsCommand(siteId));
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new MgmtDeployArtifactsCommand(siteId),
|
||||
onSuccess: json => DeployCommands.HandleSiteDeploymentResponse(
|
||||
json, CommandHelpers.ResolveFormat(result, formatOption, CliConfig.Load()), "artifact deployment"));
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
|
||||
@@ -965,6 +965,11 @@ scadabridge --url <url> site deploy-artifacts [--site-id <int>]
|
||||
|--------|----------|-------------|
|
||||
| `--site-id` | no | Target site ID; deploys system-wide artifacts to exactly that site. Omit to deploy fleet-wide to all sites. A site-scoped (non-Administrator) Deployer must supply an in-scope `--site-id`; fleet-wide deployment requires a system-wide Deployer or Administrator (arch-review C2). |
|
||||
|
||||
Output is the per-site result matrix (`siteId`, `siteName`, `success`, `errorMessage`,
|
||||
`secretsDeployed`, `secretsRemoved`) plus `successCount` / `failureCount`. The command exits `1`
|
||||
when `failureCount` is non-zero — a site that failed (unreachable, a missing or unreadable
|
||||
secret, a partial secret apply) is a failed command even though the HTTP call succeeded.
|
||||
|
||||
#### `site area list`
|
||||
|
||||
List all areas for a site.
|
||||
@@ -1107,6 +1112,8 @@ scadabridge --url <url> deploy artifacts [--site-id <int>]
|
||||
|--------|----------|-------------|
|
||||
| `--site-id` | no | Target site ID; deploys to exactly that site. Omit to deploy fleet-wide. A site-scoped (non-Administrator) Deployer must supply an in-scope `--site-id`; fleet-wide requires a system-wide Deployer or Administrator (arch-review C2). |
|
||||
|
||||
Same output and exit-code rule as `site deploy-artifacts`: exit `1` when any site failed.
|
||||
|
||||
#### `deploy status`
|
||||
|
||||
Query deployment records, with optional filters and pagination.
|
||||
|
||||
Reference in New Issue
Block a user