Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 38 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"yargs": "^17.5.1"
},
"dependencies": {
"@octopusdeploy/api-client": "^3.7.0",
"@octopusdeploy/api-client": "^3.11.0",
"azure-devops-node-api": "11.2.0",
"azure-pipelines-task-lib": "^4.13.0",
"azure-pipelines-tool-lib": "^2.0.7",
Expand Down
28 changes: 27 additions & 1 deletion source/tasks/AwaitTask/AwaitTaskV6/input-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface InputParameters {
timeout: number;
showProgress: boolean;
cancelOnTimeout: boolean;
maxRetries: number;
retryBackoffSeconds: number;
}

export function getInputParameters(logger: Logger, task: TaskWrapper): InputParameters {
Expand Down Expand Up @@ -51,14 +53,38 @@ export function getInputParameters(logger: Logger, task: TaskWrapper): InputPara

const cancelOnTimeout = task.getBoolean("CancelOnTimeout") ?? false;

let maxRetries = 3;
const maxRetriesField = task.getInput("MaxRetries");
if (maxRetriesField) {
const parsed = parseInt(maxRetriesField, 10);
if (!isNaN(parsed)) {
maxRetries = parsed;
} else {
logger.warn?.(`Invalid MaxRetries value '${maxRetriesField}', using default: 3`);
}
}

let retryBackoffSeconds = 5;
const retryBackoffField = task.getInput("RetryBackoffSeconds");
if (retryBackoffField) {
const parsed = parseInt(retryBackoffField, 10);
if (!isNaN(parsed)) {
retryBackoffSeconds = parsed;
} else {
logger.warn?.(`Invalid RetryBackoffSeconds value '${retryBackoffField}', using default: 5`);
}
}

const parameters: InputParameters = {
space: task.getInput("Space") || "",
step: step,
tasks: tasks,
showProgress: showProgress,
pollingInterval: pollingInterval,
timeout: timeoutSeconds,
cancelOnTimeout: cancelOnTimeout
cancelOnTimeout: cancelOnTimeout,
maxRetries: maxRetries,
retryBackoffSeconds: retryBackoffSeconds
};

const errors: string[] = [];
Expand Down
16 changes: 16 additions & 0 deletions source/tasks/AwaitTask/AwaitTaskV6/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@
"defaultValue": "false",
"required": false,
"helpMarkDown": "Cancel the Octopus task and mark this task as failed if the timeout is reached. (Default: false)"
},
{
"name": "MaxRetries",
"type": "int",
"label": "Max Retries",
"defaultValue": "3",
"required": false,
"helpMarkDown": "Number of times to retry failed HTTP requests due to network issues before failing. (Default: 3)"
},
{
"name": "RetryBackoffSeconds",
"type": "int",
"label": "Retry Backoff (seconds)",
"defaultValue": "5",
"required": false,
"helpMarkDown": "Initial delay between retries. Delay doubles with each retry (exponential backoff). (Default: 5s, then 10s, 20s, etc.)"
}
],
"outputVariables": [
Expand Down
35 changes: 30 additions & 5 deletions source/tasks/AwaitTask/AwaitTaskV6/waiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,31 @@ export class Waiter {
this.task.setOutputVariable("server_task_results", JSON.stringify(waitExecutionResults));

} catch (error) {
if (error instanceof Error && error.message.includes("Timeout reached") && error.message.includes("cancelled")) {
this.task.setFailure(error.message);
if (error instanceof Error) {
if (error.message.includes("Timeout reached") && error.message.includes("cancelled")) {
this.task.setFailure(error.message);
this.task.setOutputVariable("completed_successfully", "false");
return;
}

if (error.message.includes("Failed to connect to Octopus server after")) {
this.task.setFailure(
`${error.message}\n\n` +
`This indicates repeated network failures. You can:\n` +
`- Check network connectivity between ADO agent and Octopus server\n` +
`- Increase MaxRetries or RetryBackoffSeconds parameters\n` +
`- Check Octopus server health and logs`
);
} else if (error.message.includes("Unknown task Id")) {
this.task.setFailure(error.message);
} else {
this.task.setFailure(`Failed to wait for tasks: ${error.message}`);
}

this.task.setOutputVariable("completed_successfully", "false");
return;
}

this.task.setFailure(`Failed to wait for tasks: ${error}`);
this.task.setOutputVariable("completed_successfully", "false");
}
Expand All @@ -71,7 +90,10 @@ export class Waiter {
}

async waitWithoutProgress(client: Client, inputParameters: InputParameters): Promise<WaitExecutionResult[]> {
const waiter = new ServerTaskWaiter(client, inputParameters.space);
const waiter = new ServerTaskWaiter(client, inputParameters.space, {
maxRetries: inputParameters.maxRetries,
retryBackoffMs: inputParameters.retryBackoffSeconds * 1000,
});
const taskIds = inputParameters.tasks.map((t) => t.serverTaskId);
const lookup = new Map(inputParameters.tasks.map((t) => [t.serverTaskId, t]));

Expand All @@ -97,7 +119,10 @@ export class Waiter {
}

async waitWithProgress(client: Client, inputParameters: InputParameters): Promise<WaitExecutionResult[]> {
const waiter = new ServerTaskWaiter(client, inputParameters.space);
const waiter = new ServerTaskWaiter(client, inputParameters.space, {
maxRetries: inputParameters.maxRetries,
retryBackoffMs: inputParameters.retryBackoffSeconds * 1000,
});
const taskIds = inputParameters.tasks.map((t) => t.serverTaskId);
const taskLookup = new Map(inputParameters.tasks.map((t) => [t.serverTaskId, t]));

Expand Down
Loading
Loading