Skip to content

Commit

Permalink
fix: Include the step identifier in the user agent string (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
slewis74 authored Jan 17, 2023
1 parent b444dd6 commit 69eb8fa
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class BuildInformation {
this.tool.arg(["--package-id", item]);
}

await executeTask(this.tool, this.connection, "Build information successfully pushed.", "Failed to push build information.", additionalArguments);
await executeTask(this.tool, "(build-information;push;v5)", this.connection, "Build information successfully pushed.", "Failed to push build information.", additionalArguments);
}

private getVcsTypeFromProvider = (buildRepositoryProvider: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export class CreateRelease {
this.tool.arg(["--tenantTag", item]);
}

await executeTask(this.tool, this.connection, "Create release succeeded.", "Failed to create release.", additionalArguments);
await executeTask(this.tool, "(release;create;v5)", this.connection, "Create release succeeded.", "Failed to create release.", additionalArguments);
}
}
7 changes: 6 additions & 1 deletion source/tasks/Deploy/DeployV5/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export class Deploy {
this.tool.arg(["--tenantTag", item]);
}

await executeTask(this.tool, this.connection, "Deployment succeeded.", "Failed to deploy release.", additionalArguments);
let stepIdentifier = "(release;deploy;v5)";
if (deployForTenants.length > 0 || deployForTenantTags.length > 0) {
stepIdentifier = "(release;deploy-tenanted;v5)";
}

await executeTask(this.tool, stepIdentifier, this.connection, "Deployment succeeded.", "Failed to deploy release.", additionalArguments);
}
}
2 changes: 1 addition & 1 deletion source/tasks/OctoCli/OctoCliV5/octoCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export class OctoCli {

public async run(args: string | undefined) {
this.tool.arg(this.command);
await executeTask(this.tool, this.connection, "Succeeded executing octo command.", "Failed to execute octo command.", args);
await executeTask(this.tool, "(cli;run;v5)", this.connection, "Succeeded executing octo command.", "Failed to execute octo command.", args);
}
}
2 changes: 1 addition & 1 deletion source/tasks/Promote/PromoteV5/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export class Promote {
this.tool.arg(["--tenantTag", item]);
}

await executeTask(this.tool, this.connection, "Promote release succeeded.", "Failed to promote release.", additionalArguments);
await executeTask(this.tool, "(release;promote;v5)", this.connection, "Promote release succeeded.", "Failed to promote release.", additionalArguments);
}
}
2 changes: 1 addition & 1 deletion source/tasks/Push/PushV5/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Push {
this.tool.arg(["--package", item]);
}

await executeTask(this.tool, this.connection, "Package(s) pushed.", "Failed to push package(s).", additionalArguments);
await executeTask(this.tool, "(package;push;v5)", this.connection, "Package(s) pushed.", "Failed to push package(s).", additionalArguments);
}

private resolveGlobs = async (globs: string[]): Promise<string[]> => {
Expand Down
4 changes: 2 additions & 2 deletions source/tasks/Utils/octopusTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { OctoServerConnectionDetails } from "./connection";
import { connectionArguments, includeAdditionalArgumentsAndProxyConfig } from "./inputs";
import { OctopusToolRunner, runOctopusCli } from "./tool";

export async function executeTask(tool: OctopusToolRunner, connection: OctoServerConnectionDetails, successMessage: string, failureMessage: string, additionalArguments?: string | undefined) {
export async function executeTask(tool: OctopusToolRunner, stepIdentifier: string, connection: OctoServerConnectionDetails, successMessage: string, failureMessage: string, additionalArguments?: string | undefined) {
return executeWithSetResult(
async () => {
connectionArguments(connection, tool);
includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments, tool);

await runOctopusCli(tool);
await runOctopusCli(tool, stepIdentifier);
},
successMessage,
failureMessage
Expand Down
8 changes: 4 additions & 4 deletions source/tasks/Utils/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { IExecOptions } from "azure-pipelines-task-lib/toolrunner";
import Q from "q";
import * as tasks from "azure-pipelines-task-lib";

function getExecOptions(): IExecOptions {
return { env: { OCTOEXTENSION: process.env.EXTENSION_VERSION, ...process.env } };
function getExecOptions(stepIdentifier: string): IExecOptions {
return { env: { OCTOEXTENSION: `${process.env.EXTENSION_VERSION} ${stepIdentifier}`, ...process.env } };
}

export function runOctopusCli(tool: OctopusToolRunner) {
return tool.exec(getExecOptions());
export function runOctopusCli(tool: OctopusToolRunner, stepIdentifier: string) {
return tool.exec(getExecOptions(stepIdentifier));
}

export interface OctopusToolRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(build-information;push;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(release;create;v3)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function run() {
configure.push(includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments));

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(release;create;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
7 changes: 6 additions & 1 deletion source/tasksLegacy/Deploy/DeployV3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ async function run() {
includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments),
];

let stepIdentifier = "(release;deploy;v3)";
if (deploymentForTenants.length > 0 || deployForTenantTags.length > 0) {
stepIdentifier = "(release;deploy-tenanted;v3)";
}

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, stepIdentifier))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
7 changes: 6 additions & 1 deletion source/tasksLegacy/Deploy/DeployV4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ async function run() {
includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments),
];

let stepIdentifier = "(release;deploy;v4)";
if (deployForTenants.length > 0 || deployForTenantTags.length > 0) {
stepIdentifier = "(release;deploy-tenanted;v4)";
}

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, stepIdentifier))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/OctoCli/OctoCliV4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function run() {
const configure = [connectionArguments(connection), includeAdditionalArguments(args)];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(cli;run;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/Pack/PackV4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Alternatively, if NuGet package metadata is required, consider using the 'NuGet'
const configureTool = configure(getInputs());

const code: number = await octo
.map((x) => x.launchOcto(configureTool))
.map((x) => x.launchOcto(configureTool, "(package;pack;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/Promote/PromoteV3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(release;promote;v3)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/Promote/PromoteV4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(release;promote;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/Push/PushV3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(package;push;v3)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
2 changes: 1 addition & 1 deletion source/tasksLegacy/Push/PushV4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function run() {
];

const code: number = await octo
.map((x) => x.launchOcto(configure))
.map((x) => x.launchOcto(configure, "(package;push;v4)"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down
14 changes: 7 additions & 7 deletions source/tasksLegacy/Utils/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ export class OctoLauncher {
this.runner = runner;
}

private getExecOptions(): IExecOptions {
return { env: { OCTOEXTENSION: process.env.EXTENSION_VERSION, ...process.env } };
private getExecOptions(stepIdentifier: string): IExecOptions {
return { env: { OCTOEXTENSION: `${process.env.EXTENSION_VERSION} ${stepIdentifier}`, ...process.env } };
}

public launchOcto(configurations: Array<(tool: ToolRunner) => ToolRunner>): Q.Promise<number> {
public launchOcto(configurations: Array<(tool: ToolRunner) => ToolRunner>, stepIdentifier: string): Q.Promise<number> {
configureTool(configurations)(this.runner);

return this.runner.exec(this.getExecOptions());
return this.runner.exec(this.getExecOptions(stepIdentifier));
}

public launchOctoSync(configurations: Array<(tool: ToolRunner) => ToolRunner>): IExecSyncResult {
public launchOctoSync(configurations: Array<(tool: ToolRunner) => ToolRunner>, stepIdentifier: string): IExecSyncResult {
configureTool(configurations)(this.runner);

return this.runner.execSync(this.getExecOptions());
return this.runner.execSync(this.getExecOptions(stepIdentifier));
}
}

Expand Down Expand Up @@ -90,7 +90,7 @@ export function getPortableOctoCommandRunner(command: string): Option<ToolRunner
export const assertOctoVersionAcceptsIds = async function (): Promise<void> {
const octo = await getOrInstallOctoCommandRunner("version");
const result = octo
.map((x) => x.launchOctoSync([]))
.map((x) => x.launchOctoSync([], "version"))
.getOrElseL((x) => {
throw new Error(x);
});
Expand Down

0 comments on commit 69eb8fa

Please sign in to comment.