Skip to content

Commit 67abd21

Browse files
Improve messaging
1 parent 7ac2f1c commit 67abd21

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

dist/index.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67481,7 +67481,6 @@ async function deprovisionEphemeralEnvironmentForAllProjects(environment, spaceN
6748167481
if (!deprovisioningResponse.DeprovisioningRuns) {
6748267482
throw new Error(`Error deprovisioning environment: '${environment.Name}'.`);
6748367483
}
67484-
client.info(`Deprovisioning started successfully.`);
6748567484
// Returns an empty array in the case where no projects have a deprovisioning runbook
6748667485
return deprovisioningResponse.DeprovisioningRuns;
6748767486
}
@@ -67491,7 +67490,6 @@ async function deprovisionEphemeralEnvironmentForProject(environment, projectId,
6749167490
if (!deprovisioningResponse) {
6749267491
throw new Error(`Error deprovisioning environment: '${environment.Name}'.`);
6749367492
}
67494-
client.info(`Deprovisioning started successfully.`);
6749567493
// Returns undefined in the case where the project does not have a deprovisioning runbook
6749667494
return deprovisioningResponse.DeprovisioningRun || undefined;
6749767495
}
@@ -67551,27 +67549,30 @@ async function deprovisionEnvironment(context) {
6755167549
serverTaskId: run.TaskId,
6755267550
};
6755367551
})));
67554-
if (deprovisioningRuns.length > 0) {
67555-
client.info([
67556-
`🎉 Deprovisioning runbook runs:`,
67557-
...deprovisioningRuns.map(run => ` runbookRunId: ${run.RunbookRunId}, serverTaskId: ${run.TaskId}`),
67558-
`Check the status of all runbook runs to confirm that deprovisioning has completed successfully.`
67559-
].join('\n'));
67560-
}
6756167552
context.writeStepSummary(`🐙 Octopus Deploy is deprovisioning ephemeral environment **${parameters.name}**.`);
6756267553
}
6756367554
async function deprovisionEphemeralEnvironmentFromInputs(client, parameters, context) {
67555+
if (!parameters.allProjects && !parameters.project) {
67556+
throw new Error("To deprovision for a single project a project name must be provided.");
67557+
}
6756467558
const environment = await (0, api_wrapper_1.getEnvironmentByName)(parameters.name, parameters.space, client);
6756567559
if (!environment) {
6756667560
client.info(`🚩 Has your environment already been deprovisioned? No environment was found with the name: '${parameters.name}'. Skipping deprovisioning.`);
6756767561
return [];
6756867562
}
67569-
if (!parameters.allProjects && !parameters.project) {
67570-
throw new Error("To deprovision for a single project a project name must be provided.");
67571-
}
6757267563
if (parameters.allProjects) {
6757367564
client.info(`🐙 Deprovisioning ephemeral environment '${parameters.name}' for all projects in Octopus Deploy...`);
6757467565
const deprovisioningRunbookRuns = await (0, api_wrapper_1.deprovisionEphemeralEnvironmentForAllProjects)(environment, parameters.space, client);
67566+
if (deprovisioningRunbookRuns.length == 0) {
67567+
client.info(`🎉 Deprovisioning completed with no runbook runs required.`);
67568+
}
67569+
else {
67570+
client.info([
67571+
`🎉 Deprovisioning runbook runs created:`,
67572+
...deprovisioningRunbookRuns.map(run => ` runbookRunId: ${run.RunbookRunId}, serverTaskId: ${run.TaskId}`),
67573+
`Check the status of all runbook runs to confirm that deprovisioning has completed successfully.`
67574+
].join('\n'));
67575+
}
6757567576
return deprovisioningRunbookRuns;
6757667577
}
6757767578
else {
@@ -67583,11 +67584,16 @@ async function deprovisionEphemeralEnvironmentFromInputs(client, parameters, con
6758367584
return [];
6758467585
}
6758567586
const deprovisioningRunbookRun = await (0, api_wrapper_1.deprovisionEphemeralEnvironmentForProject)(environment, project.Id, parameters.space, client);
67586-
client.info(`Deprovisioning started successfully.`);
6758767587
if (!deprovisioningRunbookRun) {
67588+
client.info(`🎉 Deprovisioning completed with no runbook runs required.`);
6758867589
return [];
6758967590
}
6759067591
else {
67592+
client.info([
67593+
`🎉 Deprovisioning runbook run created:`,
67594+
` runbookRunId: ${deprovisioningRunbookRun.RunbookRunId}, serverTaskId: ${deprovisioningRunbookRun.TaskId}`,
67595+
`Check the status of the runbook run to confirm that deprovisioning has completed successfully.`
67596+
].join('\n'));
6759167597
return [deprovisioningRunbookRun];
6759267598
}
6759367599
}

src/api-wrapper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export async function deprovisionEphemeralEnvironmentForAllProjects(environment:
1414
if (!deprovisioningResponse.DeprovisioningRuns) {
1515
throw new Error(`Error deprovisioning environment: '${environment.Name}'.`);
1616
}
17-
client.info(`Deprovisioning started successfully.`);
1817

1918
// Returns an empty array in the case where no projects have a deprovisioning runbook
2019
return deprovisioningResponse.DeprovisioningRuns;
@@ -26,7 +25,6 @@ export async function deprovisionEphemeralEnvironmentForProject(environment: Dep
2625
if (!deprovisioningResponse) {
2726
throw new Error(`Error deprovisioning environment: '${environment.Name}'.`);
2827
}
29-
client.info(`Deprovisioning started successfully.`);
3028

3129
// Returns undefined in the case where the project does not have a deprovisioning runbook
3230
return deprovisioningResponse.DeprovisioningRun || undefined;

src/deprovisionEnvironment.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,39 @@ export async function deprovisionEnvironment(context: ActionContext): Promise<vo
2727
}))
2828
);
2929

30-
if (deprovisioningRuns.length > 0) {
31-
client.info([
32-
`🎉 Deprovisioning runbook runs:`,
33-
...deprovisioningRuns.map(run => ` runbookRunId: ${run.RunbookRunId}, serverTaskId: ${run.TaskId}`),
34-
`Check the status of all runbook runs to confirm that deprovisioning has completed successfully.`
35-
].join('\n'));
36-
}
30+
3731

3832
context.writeStepSummary(`🐙 Octopus Deploy is deprovisioning ephemeral environment **${parameters.name}**.`);
3933
}
4034

4135
export async function deprovisionEphemeralEnvironmentFromInputs(client: Client, parameters: InputParameters, context: ActionContext): Promise<DeprovisioningRunbookRun[]> {
36+
37+
if (!parameters.allProjects && !parameters.project) {
38+
throw new Error("To deprovision for a single project a project name must be provided.");
39+
}
4240

4341
const environment = await getEnvironmentByName(parameters.name, parameters.space, client);
4442
if (!environment) {
4543
client.info(`🚩 Has your environment already been deprovisioned? No environment was found with the name: '${parameters.name}'. Skipping deprovisioning.`);
4644
return [];
4745
}
4846

49-
if (!parameters.allProjects && !parameters.project) {
50-
throw new Error("To deprovision for a single project a project name must be provided.");
51-
}
52-
5347
if (parameters.allProjects) {
5448
client.info(`🐙 Deprovisioning ephemeral environment '${parameters.name}' for all projects in Octopus Deploy...`);
5549
const deprovisioningRunbookRuns = await deprovisionEphemeralEnvironmentForAllProjects(environment, parameters.space, client);
56-
return deprovisioningRunbookRuns;
50+
51+
if (deprovisioningRunbookRuns.length == 0) {
52+
client.info(`🎉 Deprovisioning completed with no runbook runs required.`)
53+
} else {
54+
client.info([
55+
`🎉 Deprovisioning runbook runs created:`,
56+
...deprovisioningRunbookRuns.map(run => ` runbookRunId: ${run.RunbookRunId}, serverTaskId: ${run.TaskId}`),
57+
`Check the status of all runbook runs to confirm that deprovisioning has completed successfully.`
58+
].join('\n'));
59+
}
5760

61+
return deprovisioningRunbookRuns;
62+
5863
} else {
5964
client.info(`🐙 Deprovisioning ephemeral environment '${parameters.name}' for project '${parameters.project}' in Octopus Deploy...`);
6065
const project = await GetProjectByName(client, parameters.project!, parameters.space, context);
@@ -66,10 +71,17 @@ export async function deprovisionEphemeralEnvironmentFromInputs(client: Client,
6671
}
6772

6873
const deprovisioningRunbookRun = await deprovisionEphemeralEnvironmentForProject(environment, project.Id, parameters.space, client);
69-
client.info(`Deprovisioning started successfully.`);
7074
if (!deprovisioningRunbookRun) {
75+
client.info(`🎉 Deprovisioning completed with no runbook runs required.`)
76+
7177
return [];
7278
} else {
79+
client.info([
80+
`🎉 Deprovisioning runbook run created:`,
81+
` runbookRunId: ${deprovisioningRunbookRun.RunbookRunId}, serverTaskId: ${deprovisioningRunbookRun.TaskId}`,
82+
`Check the status of the runbook run to confirm that deprovisioning has completed successfully.`
83+
].join('\n'));
84+
7385
return [deprovisioningRunbookRun];
7486
}
7587
}

0 commit comments

Comments
 (0)