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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
checks: write
strategy:
matrix:
os: [windows-2022, ubuntu-20.04, macos-14]
os: [windows-2022, ubuntu-22.04, macos-14]
steps:
- uses: actions/checkout@v3
- name: Use Node.js
Expand Down
11 changes: 6 additions & 5 deletions source/tasks/AwaitTask/AwaitTaskV6/waiter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActivityElement, ActivityLogEntryCategory, ActivityStatus, Client, Logger, ServerTaskWaiter, SpaceRepository, SpaceServerTaskRepository, TaskState } from "@octopusdeploy/api-client";
import { OctoServerConnectionDetails } from "tasks/Utils/connection";
import { getDeepLink, OctoServerConnectionDetails } from "tasks/Utils/connection";
import { TaskWrapper } from "tasks/Utils/taskInput";
import { getInputParameters, InputParameters } from "./input-parameters";
import { ExecutionResult } from "../../Utils/executionResult";
Expand All @@ -10,7 +10,7 @@ export interface WaitExecutionResult extends ExecutionResult {
}

export class Waiter {
constructor(readonly connection: OctoServerConnectionDetails, readonly task: TaskWrapper, readonly logger: Logger) { }
constructor(readonly connection: OctoServerConnectionDetails, readonly task: TaskWrapper, readonly logger: Logger) {}

public async run() {
const inputParameters = getInputParameters(this.logger, this.task);
Expand All @@ -19,15 +19,16 @@ export class Waiter {

const waitExecutionResults = inputParameters.showProgress ? await this.waitWithProgress(client, inputParameters) : await this.waitWithoutProgress(client, inputParameters);

const url = this.connection.url;
const spaceId = await this.getSpaceId(client, inputParameters.space);
let failedDeploymentsCount = 0;
waitExecutionResults.map((r) => {
const url = `${this.connection.url}app#/${spaceId}/tasks/${r.serverTaskId}`;
const link = getDeepLink(url, `${spaceId}/tasks/${r.serverTaskId}`);
const context = this.getContext(r);
if (r.successful) {
this.logger.info?.(`Succeeded: ${url}`);
this.logger.info?.(`Succeeded: ${link}`);
} else {
this.logger.warn?.(`Failed: ${url}`);
this.logger.warn?.(`Failed: ${link}`);
failedDeploymentsCount++;
}
this.task.setOutputVariable(`${context}.completed_successfully`, r.successful.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
Client,
CreateReleaseCommandV1,
Logger,
Project,
ProjectRepository,
resolveSpaceId,
} from "@octopusdeploy/api-client";
import { OctoServerConnectionDetails } from "../../Utils/connection";
import { Client, CreateReleaseCommandV1, Logger, Project, ProjectRepository, resolveSpaceId } from "@octopusdeploy/api-client";
import { getDeepLink, OctoServerConnectionDetails } from "../../Utils/connection";
import { createReleaseFromInputs } from "./createRelease";
import { createCommandFromInputs } from "./inputCommandBuilder";
import os from "os";
Expand Down Expand Up @@ -45,7 +38,7 @@ export class Release {
const projects = await projectRepo.list({ partialName: command.ProjectName });
const matchedProjects = projects.Items.filter((p: Project) => p.Name.localeCompare(command.ProjectName) === 0);
if (matchedProjects.length === 1) {
const link = `${this.connection.url}app#/${spaceId}/projects/${matchedProjects[0].Id}/deployments/releases/${version}`;
const link = getDeepLink(this.connection.url, `${spaceId}/projects/${matchedProjects[0].Id}/deployments/releases/${version}`);
const markdown = `[Release ${version} created for '${matchedProjects[0].Name}'](${link})`;
const markdownFile = path.join(getVstsEnvironmentVariables().defaultWorkingDirectory, `${uuidv4()}.md`);
tasks.writeFile(markdownFile, markdown);
Expand Down
4 changes: 2 additions & 2 deletions source/tasks/Deploy/DeployV6/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client, CreateDeploymentUntenantedCommandV1, Logger, resolveSpaceId, ServerTask, SpaceServerTaskRepository } from "@octopusdeploy/api-client";
import { OctoServerConnectionDetails } from "../../Utils/connection";
import { getDeepLink, OctoServerConnectionDetails } from "../../Utils/connection";
import { createDeploymentFromInputs } from "./createDeployment";
import { createCommandFromInputs } from "./inputCommandBuilder";
import os from "os";
Expand Down Expand Up @@ -51,7 +51,7 @@ export class Deploy {
results.forEach(function (result) {
const task = taskLookup.get(result.serverTaskId);
if (task != null) {
const link = `${url}app#/${spaceId}/deployments/${task.Arguments.DeploymentId}`;
const link = getDeepLink(url, `${spaceId}/deployments/${task.Arguments.DeploymentId}`);
markdown += `[${result.environmentName}](${link})\n`;
}
});
Expand Down
4 changes: 2 additions & 2 deletions source/tasks/DeployTenant/TenantedDeployV6/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateDeploymentTenantedCommandV1, Logger, Client, resolveSpaceId, SpaceServerTaskRepository, ServerTask } from "@octopusdeploy/api-client";
import { OctoServerConnectionDetails } from "../../Utils/connection";
import { getDeepLink, OctoServerConnectionDetails } from "../../Utils/connection";
import { createDeploymentFromInputs } from "./createDeployment";
import { createCommandFromInputs } from "./inputCommandBuilder";
import os from "os";
Expand Down Expand Up @@ -52,7 +52,7 @@ export class Deploy {
results.forEach(function (result) {
const task = taskLookup.get(result.serverTaskId);
if (task != null) {
const link = `${url}app#/${spaceId}/deployments/${task.Arguments.DeploymentId}`;
const link = getDeepLink(url, `${spaceId}/deployments/${task.Arguments.DeploymentId}`);
markdown += `[${result.tenantName}](${link})\n`;
}
});
Expand Down
15 changes: 15 additions & 0 deletions source/tasks/Utils/connection.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getDeepLink } from "./connection";

describe("DeepLinks", () => {
test("URL ends with / returns correctly formatted deep link", async () => {
const url = "https://octopus.com/vdir/";
const expectedDeepLink = "https://octopus.com/vdir/app#/Spaces-1/deployments/Deployments-1";
expect(getDeepLink(url, "Spaces-1/deployments/Deployments-1")).toBe(expectedDeepLink);
});

test("URL does not end with / return correctly formatted deep link", async () => {
const url = "https://octopus.com/vdir";
const expectedDeepLink = "https://octopus.com/vdir/app#/Spaces-1/deployments/Deployments-1";
expect(getDeepLink(url, "Spaces-1/deployments/Deployments-1")).toBe(expectedDeepLink);
});
});
7 changes: 7 additions & 0 deletions source/tasks/Utils/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ function getOctopusConnectionDetails(name: string): OctoServerConnectionDetails
ignoreSslErrors: !!ignoreSSL && ignoreSSL.toLowerCase() === "true",
};
}

export function getDeepLink(baseUrl: string, path: string): string {
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
}
return `${baseUrl}/app#/${path}`;
}
Loading