From 9524e86f2d4553a2d21a04a4276686a20e0df017 Mon Sep 17 00:00:00 2001 From: Shane Date: Thu, 11 Jan 2024 15:44:44 +1000 Subject: [PATCH] Remove legacy tasks --- .../CreateOctopusReleaseV3/icon.png | Bin 343 -> 0 bytes .../CreateOctopusReleaseV3/icon.svg | 1 - .../CreateOctopusReleaseV3/index.ts | 75 ----- .../CreateOctopusReleaseV3/task.json | 223 --------------- .../CreateOctopusReleaseV4/icon.png | Bin 343 -> 0 bytes .../CreateOctopusReleaseV4/icon.svg | 1 - .../CreateOctopusReleaseV4/index.ts | 83 ------ .../CreateOctopusReleaseV4/task.json | 266 ------------------ source/tasksLegacy/Deploy/DeployV3/icon.png | Bin 454 -> 0 bytes source/tasksLegacy/Deploy/DeployV3/icon.svg | 1 - source/tasksLegacy/Deploy/DeployV3/index.ts | 59 ---- source/tasksLegacy/Deploy/DeployV3/task.json | 164 ----------- source/tasksLegacy/Deploy/DeployV4/icon.png | Bin 454 -> 0 bytes source/tasksLegacy/Deploy/DeployV4/icon.svg | 1 - source/tasksLegacy/Deploy/DeployV4/index.ts | 59 ---- source/tasksLegacy/Deploy/DeployV4/task.json | 182 ------------ source/tasksLegacy/OctoCli/OctoCliV4/icon.png | Bin 481 -> 0 bytes source/tasksLegacy/OctoCli/OctoCliV4/icon.svg | 1 - source/tasksLegacy/OctoCli/OctoCliV4/index.ts | 33 --- .../tasksLegacy/OctoCli/OctoCliV4/task.json | 56 ---- .../OctoInstaller/OctoInstallerV4/icon.png | Bin 600 -> 0 bytes .../OctoInstaller/OctoInstallerV4/icon.svg | 1 - .../OctoInstaller/OctoInstallerV4/index.ts | 43 --- .../OctoInstaller/OctoInstallerV4/task.json | 49 ---- .../OctopusMetadataV4/icon.png | Bin 481 -> 0 bytes .../OctopusMetadataV4/icon.svg | 1 - .../OctopusMetadataV4/index.ts | 97 ------- .../OctopusMetadataV4/task.json | 97 ------- source/tasksLegacy/Pack/PackV4/icon.png | Bin 399 -> 0 bytes source/tasksLegacy/Pack/PackV4/icon.svg | 1 - source/tasksLegacy/Pack/PackV4/index.ts | 115 -------- source/tasksLegacy/Pack/PackV4/task.json | 179 ------------ source/tasksLegacy/Promote/PromoteV3/icon.png | Bin 621 -> 0 bytes source/tasksLegacy/Promote/PromoteV3/icon.svg | 1 - source/tasksLegacy/Promote/PromoteV3/index.ts | 55 ---- .../tasksLegacy/Promote/PromoteV3/task.json | 173 ------------ source/tasksLegacy/Promote/PromoteV4/icon.png | Bin 621 -> 0 bytes source/tasksLegacy/Promote/PromoteV4/icon.svg | 1 - source/tasksLegacy/Promote/PromoteV4/index.ts | 55 ---- .../tasksLegacy/Promote/PromoteV4/task.json | 195 ------------- source/tasksLegacy/Push/PushV3/icon.png | Bin 481 -> 0 bytes source/tasksLegacy/Push/PushV3/icon.svg | 1 - source/tasksLegacy/Push/PushV3/index.ts | 47 ---- source/tasksLegacy/Push/PushV3/task.json | 76 ----- source/tasksLegacy/Push/PushV4/icon.png | Bin 481 -> 0 bytes source/tasksLegacy/Push/PushV4/icon.svg | 1 - source/tasksLegacy/Push/PushV4/index.ts | 49 ---- source/tasksLegacy/Push/PushV4/task.json | 89 ------ source/tasksLegacy/Utils/OctoApiKeyHandler.ts | 26 -- source/tasksLegacy/Utils/connection.ts | 57 ---- source/tasksLegacy/Utils/environment.ts | 243 ---------------- source/tasksLegacy/Utils/inputs.ts | 74 ----- source/tasksLegacy/Utils/install.ts | 192 ------------- source/tasksLegacy/Utils/tool.ts | 174 ------------ 54 files changed, 3297 deletions(-) delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/icon.png delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/icon.svg delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/index.ts delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/task.json delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/icon.png delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/icon.svg delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/index.ts delete mode 100644 source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/task.json delete mode 100644 source/tasksLegacy/Deploy/DeployV3/icon.png delete mode 100644 source/tasksLegacy/Deploy/DeployV3/icon.svg delete mode 100644 source/tasksLegacy/Deploy/DeployV3/index.ts delete mode 100644 source/tasksLegacy/Deploy/DeployV3/task.json delete mode 100644 source/tasksLegacy/Deploy/DeployV4/icon.png delete mode 100644 source/tasksLegacy/Deploy/DeployV4/icon.svg delete mode 100644 source/tasksLegacy/Deploy/DeployV4/index.ts delete mode 100644 source/tasksLegacy/Deploy/DeployV4/task.json delete mode 100644 source/tasksLegacy/OctoCli/OctoCliV4/icon.png delete mode 100644 source/tasksLegacy/OctoCli/OctoCliV4/icon.svg delete mode 100644 source/tasksLegacy/OctoCli/OctoCliV4/index.ts delete mode 100644 source/tasksLegacy/OctoCli/OctoCliV4/task.json delete mode 100644 source/tasksLegacy/OctoInstaller/OctoInstallerV4/icon.png delete mode 100644 source/tasksLegacy/OctoInstaller/OctoInstallerV4/icon.svg delete mode 100644 source/tasksLegacy/OctoInstaller/OctoInstallerV4/index.ts delete mode 100644 source/tasksLegacy/OctoInstaller/OctoInstallerV4/task.json delete mode 100644 source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/icon.png delete mode 100644 source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/icon.svg delete mode 100644 source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/index.ts delete mode 100644 source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/task.json delete mode 100644 source/tasksLegacy/Pack/PackV4/icon.png delete mode 100644 source/tasksLegacy/Pack/PackV4/icon.svg delete mode 100644 source/tasksLegacy/Pack/PackV4/index.ts delete mode 100644 source/tasksLegacy/Pack/PackV4/task.json delete mode 100644 source/tasksLegacy/Promote/PromoteV3/icon.png delete mode 100644 source/tasksLegacy/Promote/PromoteV3/icon.svg delete mode 100644 source/tasksLegacy/Promote/PromoteV3/index.ts delete mode 100644 source/tasksLegacy/Promote/PromoteV3/task.json delete mode 100644 source/tasksLegacy/Promote/PromoteV4/icon.png delete mode 100644 source/tasksLegacy/Promote/PromoteV4/icon.svg delete mode 100644 source/tasksLegacy/Promote/PromoteV4/index.ts delete mode 100644 source/tasksLegacy/Promote/PromoteV4/task.json delete mode 100644 source/tasksLegacy/Push/PushV3/icon.png delete mode 100644 source/tasksLegacy/Push/PushV3/icon.svg delete mode 100644 source/tasksLegacy/Push/PushV3/index.ts delete mode 100644 source/tasksLegacy/Push/PushV3/task.json delete mode 100644 source/tasksLegacy/Push/PushV4/icon.png delete mode 100644 source/tasksLegacy/Push/PushV4/icon.svg delete mode 100644 source/tasksLegacy/Push/PushV4/index.ts delete mode 100644 source/tasksLegacy/Push/PushV4/task.json delete mode 100644 source/tasksLegacy/Utils/OctoApiKeyHandler.ts delete mode 100644 source/tasksLegacy/Utils/connection.ts delete mode 100644 source/tasksLegacy/Utils/environment.ts delete mode 100644 source/tasksLegacy/Utils/inputs.ts delete mode 100644 source/tasksLegacy/Utils/install.ts delete mode 100644 source/tasksLegacy/Utils/tool.ts diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/icon.png b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/icon.png deleted file mode 100644 index cae677b4a2420bebbc5556e566c85dd97e529b39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XECYN(T=geE`2YWZ^12t(Prjdi^26yT-)&|++IRP>=fWqo zd){;%diUwa->~J+o__kh@%rZ_7e3y2{j*@}E1(w3Ig)RHh6tAg`2_>HXnF!PcEP4V^-u~4G3VIZ+!XR|KrmRniXDrm9s1J{V|t57U9<4N*mbj`92ao zU}Dd9+~1)9e6mCMS!2@Ionj`y9`Z?x?9gWgx*PExan|>FX6z;!bOZB z%-25K-r(V=XR1Evoctopus \ No newline at end of file diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/index.ts b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/index.ts deleted file mode 100644 index ebab652b..00000000 --- a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/index.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { multiArgument, connectionArguments, includeAdditionalArgumentsAndProxyConfig, flag, argumentEnquote, argumentIfSet, getOrInstallOctoCommandRunner } from "../../Utils/tool"; -import { createReleaseNotesFile, createVstsConnection, generateReleaseNotesContent, getLinkedReleaseNotes, getVstsEnvironmentVariables } from "../../Utils/environment"; -import { getDefaultOctopusConnectionDetailsOrThrow, resolveProjectName } from "../../Utils/connection"; -import { getOptionalCsvInput } from "../../Utils/inputs"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const environmentVariables = getVstsEnvironmentVariables(); - const vstsConnection = createVstsConnection(environmentVariables); - const octoConnection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - // @ts-expect-error - const project = await resolveProjectName(octoConnection, tasks.getInput("ProjectName", true)).then((x) => x.value); - const releaseNumber = tasks.getInput("ReleaseNumber"); - const channel = tasks.getInput("Channel"); - const changesetCommentReleaseNotes = tasks.getBoolInput("ChangesetCommentReleaseNotes"); - const workItemReleaseNotes = tasks.getBoolInput("WorkItemReleaseNotes"); - const customReleaseNotes = tasks.getInput("CustomReleaseNotes"); - const deployToEnvironments = getOptionalCsvInput("DeployToEnvironment"); - const deployForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTenantTags"); - const deploymentProgress = tasks.getBoolInput("DeploymentProgress"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - const octo = await getOrInstallOctoCommandRunner("create-release"); - - let linkedReleaseNotes = ""; - if (workItemReleaseNotes || changesetCommentReleaseNotes) { - linkedReleaseNotes = await getLinkedReleaseNotes(vstsConnection, changesetCommentReleaseNotes, workItemReleaseNotes); - } - - const releaseNotesFile = createReleaseNotesFile(() => { - // @ts-expect-error - return generateReleaseNotesContent(environmentVariables, linkedReleaseNotes, customReleaseNotes); - }, environmentVariables.defaultWorkingDirectory); - - const configure = [ - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - argumentEnquote("project", project), - // @ts-expect-error - argumentIfSet(argumentEnquote, "releaseNumber", releaseNumber), - // @ts-expect-error - argumentIfSet(argumentEnquote, "channel", channel), - connectionArguments(octoConnection), - flag("enableServiceMessages", true), - multiArgument(argumentEnquote, "deployTo", deployToEnvironments), - flag("progress", deployToEnvironments.length > 0 && deploymentProgress), - multiArgument(argumentEnquote, "tenant", deployForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - argumentEnquote("releaseNotesFile", releaseNotesFile), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(octoConnection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(release;create;v3)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Create octopus release succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to create release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/task.json b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/task.json deleted file mode 100644 index 331361a0..00000000 --- a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV3/task.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "id": "4E131B60-5532-4362-95B6-7C67D9841B4F", - "name": "OctopusCreateRelease", - "friendlyName": "Create Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Create a Release in Octopus Deploy", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 3, - "Minor": 1, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "releasenotes", - "displayName": "Release Notes", - "isExpanded": true - }, - { - "name": "deployment", - "displayName": "Deployment", - "isExpanded": false - }, - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "additional", - "displayName": "Additional Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "string", - "label": "Space (Legacy - Use version 4 of this task)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "False" - }, - "helpMarkDown": "Version 3 of this task has limited support for spaces. We recommend using version 4 of this task for a better experience." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "ProjectName", - "type": "pickList", - "label": "Project Name", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Octopus Deploy Project Name" - }, - { - "name": "ReleaseNumber", - "type": "string", - "label": "Release Number", - "defaultValue": "", - "required": false, - "helpMarkDown": "The number to use for this release. You can leave this blank if the release number is calculated by Octopus." - }, - { - "name": "Channel", - "type": "pickList", - "label": "Channel", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The [channel](https://g.octopushq.com/Channels) to use for the release." - }, - { - "name": "ChangesetCommentReleaseNotes", - "type": "boolean", - "label": "Include Changeset Comments", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Whether to include linked Changeset comments in Octopus Release notes.", - "groupName": "releasenotes" - }, - { - "name": "WorkItemReleaseNotes", - "type": "boolean", - "label": "Include Work Items", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Whether to include linked Work Item Titles in Octopus Release notes.", - "groupName": "releasenotes" - }, - { - "name": "CustomReleaseNotes", - "type": "string", - "label": "Custom Notes", - "defaultValue": "", - "required": false, - "helpMarkDown": "Custom notes appended to Octopus Release notes. This field supports markdown. To include newlines, you can use HTML linebreaks.", - "groupName": "releasenotes" - }, - { - "name": "DeployToEnvironment", - "type": "pickList", - "label": "To Environment", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release to this environment after creating it.", - "groupName": "deployment" - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release for this comma-delimited list of tenants after creating it. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Deploy the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "DeploymentProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Output from the deployment will appear in the log. If checked, the task will only succeed if the deployment is successful.", - "groupName": "deployment" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExeCreateRelease) for available parameters.", - "groupName": "additional" - } - ], - "dataSourceBindings": [ - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroups", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "ProjectName", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroup", - "parameters": { - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployToEnvironment", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllEnvironments", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Channel", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectChannels", - "parameters": { - "ProjectName": "$(ProjectName)" - }, - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllTenants", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Create Octopus Release: $(ProjectName)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/icon.png b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/icon.png deleted file mode 100644 index cae677b4a2420bebbc5556e566c85dd97e529b39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XECYN(T=geE`2YWZ^12t(Prjdi^26yT-)&|++IRP>=fWqo zd){;%diUwa->~J+o__kh@%rZ_7e3y2{j*@}E1(w3Ig)RHh6tAg`2_>HXnF!PcEP4V^-u~4G3VIZ+!XR|KrmRniXDrm9s1J{V|t57U9<4N*mbj`92ao zU}Dd9+~1)9e6mCMS!2@Ionj`y9`Z?x?9gWgx*PExan|>FX6z;!bOZB z%-25K-r(V=XR1Evoctopus \ No newline at end of file diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/index.ts b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/index.ts deleted file mode 100644 index b9f2fc0a..00000000 --- a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/index.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { createReleaseNotesFile, createVstsConnection, generateReleaseNotesContent, getLinkedReleaseNotes, getVstsEnvironmentVariables } from "../../Utils/environment"; -import { argumentEnquote, argumentIfSet, assertOctoVersionAcceptsIds, connectionArguments, flag, getOrInstallOctoCommandRunner, includeAdditionalArgumentsAndProxyConfig, multiArgument } from "../../Utils/tool"; -import { getOptionalCsvInput } from "../../Utils/inputs"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const environmentVariables = getVstsEnvironmentVariables(); - const vstsConnection = createVstsConnection(environmentVariables); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - const project = tasks.getInput("ProjectName", true); - const releaseNumber = tasks.getInput("ReleaseNumber"); - const channel = tasks.getInput("Channel"); - const changesetCommentReleaseNotes = tasks.getBoolInput("ChangesetCommentReleaseNotes"); - const workItemReleaseNotes = tasks.getBoolInput("WorkItemReleaseNotes"); - const customReleaseNotes = tasks.getInput("CustomReleaseNotes"); - const deployToEnvironments = getOptionalCsvInput("DeployToEnvironment"); - const deployForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTenantTags"); - const deploymentProgress = tasks.getBoolInput("DeploymentProgress"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - const gitRef = tasks.getInput("GitRef"); - const gitCommit = tasks.getInput("GitCommit"); - - await assertOctoVersionAcceptsIds(); - const octo = await getOrInstallOctoCommandRunner("create-release"); - - const configure = [ - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - // @ts-expect-error - argumentEnquote("project", project), - // @ts-expect-error - argumentIfSet(argumentEnquote, "releaseNumber", releaseNumber), - // @ts-expect-error - argumentIfSet(argumentEnquote, "channel", channel), - connectionArguments(connection), - flag("enableServiceMessages", true), - multiArgument(argumentEnquote, "deployTo", deployToEnvironments), - // @ts-expect-error - argumentIfSet(argumentEnquote, "gitRef", gitRef), - // @ts-expect-error - argumentIfSet(argumentEnquote, "gitCommit", gitCommit), - flag("progress", deployToEnvironments.length > 0 && deploymentProgress), - multiArgument(argumentEnquote, "tenant", deployForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - ]; - - if (workItemReleaseNotes || changesetCommentReleaseNotes || (customReleaseNotes && /[^\s]/.test(customReleaseNotes))) { - const linkedReleaseNotes = workItemReleaseNotes || changesetCommentReleaseNotes ? await getLinkedReleaseNotes(vstsConnection, changesetCommentReleaseNotes, workItemReleaseNotes) : ""; - - const releaseNotesFile = createReleaseNotesFile(() => { - // @ts-expect-error - return generateReleaseNotesContent(environmentVariables, linkedReleaseNotes, customReleaseNotes); - }, environmentVariables.defaultWorkingDirectory); - - configure.push(argumentEnquote("releaseNotesFile", releaseNotesFile)); - } - - // @ts-expect-error - configure.push(includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments)); - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(release;create;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Create octopus release succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to create release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/task.json b/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/task.json deleted file mode 100644 index bbcc3df2..00000000 --- a/source/tasksLegacy/CreateOctopusRelease/CreateOctopusReleaseV4/task.json +++ /dev/null @@ -1,266 +0,0 @@ -{ - "id": "4E131B60-5532-4362-95B6-7C67D9841B4F", - "name": "OctopusCreateRelease", - "friendlyName": "Create Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Create a Release in Octopus Deploy", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "releasenotes", - "displayName": "Release Notes (Legacy)", - "isExpanded": true - }, - { - "name": "deployment", - "displayName": "Deployment", - "isExpanded": false - }, - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "versionControl", - "displayName": "Version Control", - "isExpanded": false - }, - { - "name": "additional", - "displayName": "Additional Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "pickList", - "label": "Space", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The space within Octopus." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "ProjectName", - "type": "pickList", - "label": "Project", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project within Octopus." - }, - { - "name": "ReleaseNumber", - "type": "string", - "label": "Release Number", - "defaultValue": "", - "required": false, - "helpMarkDown": "The number to use for this release. You can leave this blank if the release number is calculated by Octopus." - }, - { - "name": "Channel", - "type": "pickList", - "label": "Channel", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The [channel](https://g.octopushq.com/Channels) to use for the release." - }, - { - "name": "ChangesetCommentReleaseNotes", - "type": "boolean", - "label": "Include Changeset Comments", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Whether to add linked changeset comments to Octopus Release notes.\n\n*Note: These Release Notes options are considered legacy. We recommend clearing them and pushing [Build Information](https://g.octopushq.com/BuildInformation) alongside your packages, which allows the customizable [Release Notes Template](https://g.octopushq.com/ReleaseNotesTemplate) to generate automatic release notes.*", - "groupName": "releasenotes" - }, - { - "name": "WorkItemReleaseNotes", - "type": "boolean", - "label": "Include Work Items", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Whether to add linked Work Item titles to Octopus Release notes.\n\n*Note: These Release Notes options are considered legacy. We recommend clearing them and pushing [Build Information](https://g.octopushq.com/BuildInformation) alongside your packages, which allows the customizable [Release Notes Template](https://g.octopushq.com/ReleaseNotesTemplate) to generate automatic release notes.*", - "groupName": "releasenotes" - }, - { - "name": "CustomReleaseNotes", - "type": "string", - "label": "Custom Notes", - "defaultValue": "", - "required": false, - "helpMarkDown": "Custom notes appended to Octopus Release notes. This field supports markdown. To include newlines, you can use HTML linebreaks.\n\n*Note: These Release Notes options are considered legacy. We recommend clearing them and pushing [Build Information](https://g.octopushq.com/BuildInformation) alongside your packages, which allows the customizable [Release Notes Template](https://g.octopushq.com/ReleaseNotesTemplate) to generate automatic release notes.*", - "groupName": "releasenotes" - }, - { - "name": "DeployToEnvironment", - "type": "pickList", - "label": "To Environment", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release to this environment after creating it.", - "groupName": "deployment" - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release for this comma-delimited list of tenants after creating it. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Deploy the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "DeploymentProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Output from the deployment will appear in the log. If checked, the task will only succeed if the deployment is successful.", - "groupName": "deployment" - }, - { - "name": "GitRef", - "type": "string", - "label": "Git Reference", - "defaultValue": "", - "required": false, - "helpMarkDown": "Git branch reference to use when creating the release for version controlled Projects.", - "groupName": "versionControl" - }, - { - "name": "GitCommit", - "type": "string", - "label": "Git Commit", - "defaultValue": "", - "required": false, - "helpMarkDown": "Git commit to use when creating the release for version controlled Projects. Use in conjunction with the gitRef parameter to select any previous commit.", - "groupName": "versionControl" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExeCreateRelease) for available parameters.", - "groupName": "additional" - } - ], - "dataSourceBindings": [ - { - "target": "Space", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllSpaces", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroupsInSpace", - "parameters": { - "SpaceId": "$(Space)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "ProjectName", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroupInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployToEnvironment", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectChannelEnvironmentsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectId": "$(ProjectName)", - "ChannelId": "$(Channel)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Channel", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectChannelsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectName": "$(ProjectName)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectTenantsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectName": "$(ProjectName)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Create Octopus Release", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Deploy/DeployV3/icon.png b/source/tasksLegacy/Deploy/DeployV3/icon.png deleted file mode 100644 index 591f4d253f95a8bc45cc879a1d1532641d20b54e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 454 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xk^_7~T=geEn11qoNK$_Cx)-OPeEgNJ8k}z z8@KDbCWkG5wsOOEn^})GUjO{@)8`wne`;ELA3J@%u(ti_r{AA`{PkS;WctYuU5DOT zc!byPd9&og$45_}yM-nfY<;!w?pL6Je18_l0j*Ok3GxdDa`6I&`3Em30u`U}ba4!+ zxOL|8O};}40<0GbPen}&+Pz)x@Bj58T3I1i_RaXRk4KSxMhnjwd#2S5rzaJbZ)i>_ zyUpxY%dWh%lzYLsdy?LM`3=8(CR{aPei3_LrIGbAn}Zd{Q%MW{V+{5Uc6S11v#vO) zl@;gkTxVm-PDj&R-`(5grkuR>_W#j(N9ReIc@4=+1yz&&#q8ME#Qfapn5Kq=_M=Y< zB}>H{iZxH|I4uwvBlkJzleWgBgcI$xTN!jG`+FSJ7Mv|p@V@%fa(UO5Lt*^yx5uzZ ZF!au`45>Q*R~hIp22WQ%mvv4FO#t+soctopus \ No newline at end of file diff --git a/source/tasksLegacy/Deploy/DeployV3/index.ts b/source/tasksLegacy/Deploy/DeployV3/index.ts deleted file mode 100644 index e99444b5..00000000 --- a/source/tasksLegacy/Deploy/DeployV3/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { multiArgument, connectionArguments, includeAdditionalArgumentsAndProxyConfig, flag, argumentEnquote, argumentIfSet, getOrInstallOctoCommandRunner } from "../../Utils/tool"; -import { getDefaultOctopusConnectionDetailsOrThrow, resolveProjectName } from "../../Utils/connection"; -import { getOptionalCsvInput, getRequiredCsvInput } from "../../Utils/inputs"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - const releaseNumber = tasks.getInput("ReleaseNumber", true); - const environments = getRequiredCsvInput("Environments"); - const showProgress = tasks.getBoolInput("ShowProgress"); - const deploymentForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTenantTags"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - // @ts-ignore - const project = await resolveProjectName(connection, tasks.getInput("Project", true)).then((x) => x.value); - - const octo = await getOrInstallOctoCommandRunner("deploy-release"); - - const configure = [ - // @ts-ignore - argumentIfSet(argumentEnquote, "space", space), - argumentEnquote("project", project), - // @ts-ignore - argumentEnquote("releaseNumber", releaseNumber), - connectionArguments(connection), - multiArgument(argumentEnquote, "deployTo", environments), - multiArgument(argumentEnquote, "tenant", deploymentForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - flag("progress", showProgress), - // @ts-ignore - 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, stepIdentifier)) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Deploy succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to deploy release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Deploy/DeployV3/task.json b/source/tasksLegacy/Deploy/DeployV3/task.json deleted file mode 100644 index 3274fe57..00000000 --- a/source/tasksLegacy/Deploy/DeployV3/task.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "id": "8ca1d96a-151d-44b7-bc4f-9251e2ea6971", - "name": "OctopusDeployRelease", - "friendlyName": "Deploy Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Deploy an Octopus Deploy Release", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 3, - "Minor": 1, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "string", - "label": "Space (Legacy - Use version 4 of this task)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "False" - }, - "helpMarkDown": "Version 3 of this task has limited support for spaces. We recommend using version 4 of this task for a better experience." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "Project", - "type": "pickList", - "label": "Project", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Octopus Deploy Project Name" - }, - { - "name": "ReleaseNumber", - "type": "string", - "label": "Release Number", - "defaultValue": "latest", - "required": true, - "helpMarkDown": "The number of the release to deploy. Use 'latest' to deploy the latest release." - }, - { - "name": "Environments", - "type": "pickList", - "label": "Deploy to Environments", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Comma separated list of environments to deploy to." - }, - { - "name": "ShowProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "False", - "required": false, - "helpMarkDown": "If checked, the build process will only succeed if the deployment is successful." - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release for this comma delimited list of tenants. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Deploy the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExeDeployRelease) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroups", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Project", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroup", - "parameters": { - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Environments", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllEnvironments", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllTenants", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Deploy Octopus Release: $(Project) to $(Environments)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Deploy/DeployV4/icon.png b/source/tasksLegacy/Deploy/DeployV4/icon.png deleted file mode 100644 index 591f4d253f95a8bc45cc879a1d1532641d20b54e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 454 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xk^_7~T=geEn11qoNK$_Cx)-OPeEgNJ8k}z z8@KDbCWkG5wsOOEn^})GUjO{@)8`wne`;ELA3J@%u(ti_r{AA`{PkS;WctYuU5DOT zc!byPd9&og$45_}yM-nfY<;!w?pL6Je18_l0j*Ok3GxdDa`6I&`3Em30u`U}ba4!+ zxOL|8O};}40<0GbPen}&+Pz)x@Bj58T3I1i_RaXRk4KSxMhnjwd#2S5rzaJbZ)i>_ zyUpxY%dWh%lzYLsdy?LM`3=8(CR{aPei3_LrIGbAn}Zd{Q%MW{V+{5Uc6S11v#vO) zl@;gkTxVm-PDj&R-`(5grkuR>_W#j(N9ReIc@4=+1yz&&#q8ME#Qfapn5Kq=_M=Y< zB}>H{iZxH|I4uwvBlkJzleWgBgcI$xTN!jG`+FSJ7Mv|p@V@%fa(UO5Lt*^yx5uzZ ZF!au`45>Q*R~hIp22WQ%mvv4FO#t+soctopus \ No newline at end of file diff --git a/source/tasksLegacy/Deploy/DeployV4/index.ts b/source/tasksLegacy/Deploy/DeployV4/index.ts deleted file mode 100644 index d2dd6cec..00000000 --- a/source/tasksLegacy/Deploy/DeployV4/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { argumentEnquote, argumentIfSet, assertOctoVersionAcceptsIds, connectionArguments, flag, getOrInstallOctoCommandRunner, includeAdditionalArgumentsAndProxyConfig, multiArgument } from "../../Utils/tool"; -import { getOptionalCsvInput, getRequiredCsvInput } from "../../Utils/inputs"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - const project = tasks.getInput("Project", true); - const releaseNumber = tasks.getInput("ReleaseNumber", true); - const deployToEnvironments = getRequiredCsvInput("Environments"); - const deployForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTenantTags"); - const showProgress = tasks.getBoolInput("ShowProgress"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - await assertOctoVersionAcceptsIds(); - const octo = await getOrInstallOctoCommandRunner("deploy-release"); - - const configure = [ - // @ts-ignore - argumentIfSet(argumentEnquote, "space", space), - // @ts-ignore - argumentEnquote("project", project), - // @ts-ignore - argumentEnquote("releaseNumber", releaseNumber), - connectionArguments(connection), - multiArgument(argumentEnquote, "deployTo", deployToEnvironments), - multiArgument(argumentEnquote, "tenant", deployForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - flag("progress", showProgress), - // @ts-ignore - 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, stepIdentifier)) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Deploy succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to deploy release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Deploy/DeployV4/task.json b/source/tasksLegacy/Deploy/DeployV4/task.json deleted file mode 100644 index eec3f330..00000000 --- a/source/tasksLegacy/Deploy/DeployV4/task.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "id": "8ca1d96a-151d-44b7-bc4f-9251e2ea6971", - "name": "OctopusDeployRelease", - "friendlyName": "Deploy Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Deploy an Octopus Deploy Release", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "pickList", - "label": "Space", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The space within Octopus." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "Project", - "type": "pickList", - "label": "Project", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project within Octopus." - }, - { - "name": "ReleaseNumber", - "type": "string", - "label": "Release Number", - "defaultValue": "latest", - "required": true, - "helpMarkDown": "The number of the release to deploy. Use 'latest' to deploy the latest release." - }, - { - "name": "Environments", - "type": "pickList", - "label": "Deploy to Environments", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Comma separated list of environments to deploy to." - }, - { - "name": "ShowProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "False", - "required": false, - "helpMarkDown": "If checked, the build process will only succeed if the deployment is successful." - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Deploy the release for this comma delimited list of tenants. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Deploy the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExeDeployRelease) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "Space", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllSpaces", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroupsInSpace", - "parameters": { - "SpaceId": "$(Space)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Project", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroupInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Environments", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectEnvironmentsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectId": "$(Project)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectTenantsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectName": "$(Project)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Deploy Octopus Release", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/OctoCli/OctoCliV4/icon.png b/source/tasksLegacy/OctoCli/OctoCliV4/icon.png deleted file mode 100644 index 236566a308c71c4b35ce91fa54e6914d05fb8d7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 481 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X5(0ceT=geE`2YXEw4QzPx)(OH9^H8T^V5&NwR_$iJAMB2 zlkd|{z7JdeY{`X>D>rQ4clWDC?vm|$4|^_rGX3O-f~~JMUjO{`<8KR(@UBDe9zA_7 zW8(Sr({J6jGn&@kn#Jq<8&?5MzN-Gj8RWW>AirQB7aw4ViIIK_RQuY~#WAGf)|JUO zg_;dGToq^cx@BK|*Zu$hbk@acQL?{p++$Bya%U26DRcg?yrHafN@ijhgZ4r1rD>cV z3NIEYFVJzex!AERaEc521I41Md6xGQ)F%rjx;bztnH<-Cb9A{1o6Eh}1U819ca*nG zm+fZUxZM1v#PO~^%`NJJE-iDIgrXGHTDTmJtv%Q9TK0{={z`MZhK=0Z+>-MIj5Y|y z9A0xm?Mgz*b=ND;xTpNT7s&dg{Nhgm$)%1_;l&3Qg-X3%IeF*&R+q&G0y|G#y{PkN zL&dCBCvNy}vz?b_|L$w;kE+Gn%0G$!U$dQonSt+$*N$DY75)Id&EVoctopus \ No newline at end of file diff --git a/source/tasksLegacy/OctoCli/OctoCliV4/index.ts b/source/tasksLegacy/OctoCli/OctoCliV4/index.ts deleted file mode 100644 index fcf7a196..00000000 --- a/source/tasksLegacy/OctoCli/OctoCliV4/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { connectionArguments, getOrInstallOctoCommandRunner, includeAdditionalArguments } from "../../Utils/tool"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - const args = tasks.getInput("args", false); - const command = tasks.getInput("command", true); - // @ts-ignore - const octo = await getOrInstallOctoCommandRunner(command); - - // @ts-ignore - const configure = [connectionArguments(connection), includeAdditionalArguments(args)]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(cli;run;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, `Succeeded executing octo command ${command} with code ${code}`); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to execute octo command. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/OctoCli/OctoCliV4/task.json b/source/tasksLegacy/OctoCli/OctoCliV4/task.json deleted file mode 100644 index 4553a726..00000000 --- a/source/tasksLegacy/OctoCli/OctoCliV4/task.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "id": "25fee290-e578-491b-b1db-dbc3980df1d0", - "name": "OctoCli", - "friendlyName": "Invoke Octopus CLI command", - "description": "There is a later version of this task, we recommend using the latest version. Invoke an Octopus CLI command", - "helpMarkDown": "set-by-pack.ps1", - "category": "Tool", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "command", - "type": "string", - "label": "command", - "defaultValue": "", - "required": true, - "helpMarkDown": "The Octopus CLI command to execute." - }, - { - "name": "args", - "type": "string", - "label": "arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "The arguments to use for the command." - } - ], - "instanceNameFormat": "Invoke an Octopus CLI command", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/OctoInstaller/OctoInstallerV4/icon.png b/source/tasksLegacy/OctoInstaller/OctoInstallerV4/icon.png deleted file mode 100644 index d54551d79a45027401d3d149af2619b6a48be11d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 600 zcmV-e0;m0nP)}VKg|3!E0NBpaa)2rh(A899 zhzjx2Gs_$CSwT1v;&KGY za#;2w*K(p9fXxvg%R#{p0$Y(B01_v~au5JFNCec(4lpn<*b`C=O3k2x2Ndi_HZ6r% z>KBco23NFT0S7command-line \ No newline at end of file diff --git a/source/tasksLegacy/OctoInstaller/OctoInstallerV4/index.ts b/source/tasksLegacy/OctoInstaller/OctoInstallerV4/index.ts deleted file mode 100644 index b8079c09..00000000 --- a/source/tasksLegacy/OctoInstaller/OctoInstallerV4/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import { getOrDownloadOcto, resolvePublishedOctoVersion, addToolToPath, getEmbeddedOcto } from "../../Utils/install"; -import * as tasks from "azure-pipelines-task-lib/task"; -import * as os from "os"; - -async function run() { - tasks.warning("This task is deprecated, please use latest version instead."); - const version = tasks.getInput("version"); - // @ts-ignore - const forceEmbedded = /embedded/i.test(version); - - try { - if (forceEmbedded) { - console.log("Forcing the use of the embedded Octopus CLI tool."); - await getEmbeddedOcto(tasks.resolve(__dirname, "embedded")).then(addToolToPath); - } else { - const option = await resolvePublishedOctoVersion(version); - console.log(`Using Octopus CLI tool version ${option.version}`); - await getOrDownloadOcto(option).then(addToolToPath); - } - - tasks.setResult(tasks.TaskResult.Succeeded, ""); - } catch (error: unknown) { - if (error instanceof Error) { - if (forceEmbedded) { - tasks.setResult(tasks.TaskResult.Failed, `${error.message}${os.EOL}${error.stack}`, true); - return; - } - - console.log(`Failed to resolve Octopus CLI tool version ${version}. Using the embedded version. ${error}`); - - try { - await getEmbeddedOcto(tasks.resolve(__dirname, "embedded")).then(addToolToPath); - } catch (embeddedOctoError: unknown) { - if (embeddedOctoError instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `${embeddedOctoError.message}${os.EOL}${embeddedOctoError.stack}`, true); - } - } - } - } -} - -run(); diff --git a/source/tasksLegacy/OctoInstaller/OctoInstallerV4/task.json b/source/tasksLegacy/OctoInstaller/OctoInstallerV4/task.json deleted file mode 100644 index a1df9e46..00000000 --- a/source/tasksLegacy/OctoInstaller/OctoInstallerV4/task.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "id": "57342b23-3a76-490a-8e78-25d4ade2f2e3", - "name": "OctoInstaller", - "friendlyName": "[DEPRECATED] Octopus CLI Installer", - "description": "This task is deprecated, please use latest version instead. Install a specific version of the Octopus CLI", - "helpMarkDown": "Install a specific version of the Octopus CLI", - "category": "Tool", - "runsOn": [ - "Agent", - "DeploymentGroup" - ], - "visibility": [ - "Build", - "Release" - ], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "deprecated": true, - "satisfies": ["Octo"], - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "version", - "type": "string", - "label": "Octopus CLI Version", - "defaultValue": "embedded", - "required": true, - "helpMarkDown": "Specify `latest` or the version number to download. If you specify `embedded`, or the download fails, a built-in copy of the tool will be used." - } - ], - "instanceNameFormat": "[DEPRECATED] Use Octopus CLI tool version $(version)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/icon.png b/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/icon.png deleted file mode 100644 index 236566a308c71c4b35ce91fa54e6914d05fb8d7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 481 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X5(0ceT=geE`2YXEw4QzPx)(OH9^H8T^V5&NwR_$iJAMB2 zlkd|{z7JdeY{`X>D>rQ4clWDC?vm|$4|^_rGX3O-f~~JMUjO{`<8KR(@UBDe9zA_7 zW8(Sr({J6jGn&@kn#Jq<8&?5MzN-Gj8RWW>AirQB7aw4ViIIK_RQuY~#WAGf)|JUO zg_;dGToq^cx@BK|*Zu$hbk@acQL?{p++$Bya%U26DRcg?yrHafN@ijhgZ4r1rD>cV z3NIEYFVJzex!AERaEc521I41Md6xGQ)F%rjx;bztnH<-Cb9A{1o6Eh}1U819ca*nG zm+fZUxZM1v#PO~^%`NJJE-iDIgrXGHTDTmJtv%Q9TK0{={z`MZhK=0Z+>-MIj5Y|y z9A0xm?Mgz*b=ND;xTpNT7s&dg{Nhgm$)%1_;l&3Qg-X3%IeF*&R+q&G0y|G#y{PkN zL&dCBCvNy}vz?b_|L$w;kE+Gn%0G$!U$dQonSt+$*N$DY75)Id&EVoctopus \ No newline at end of file diff --git a/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/index.ts b/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/index.ts deleted file mode 100644 index 973ac51a..00000000 --- a/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/index.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { ToolRunner } from "azure-pipelines-task-lib/toolrunner"; -import * as path from "path"; -import { createVstsConnection, getBuildBranch, getBuildChanges, getVcsTypeFromProvider, getVstsEnvironmentVariables } from "../../Utils/environment"; -import { getLineSeparatedItems, getOverwriteModeFromReplaceInput } from "../../Utils/inputs"; -import { assertOctoVersionAcceptsIds, getOrInstallOctoCommandRunner, connectionArguments, includeAdditionalArgumentsAndProxyConfig, argument, argumentEnquote, argumentIfSet, multiArgument } from "../../Utils/tool"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -export interface IOctopusBuildInformation { - BuildEnvironment: string; - BuildNumber: string; - BuildUrl: string; - Branch: string; - VcsType: string; - VcsRoot: string; - VcsCommitNumber: string; - Commits: IOctopusBuildInformationCommit[]; -} - -export interface IOctopusBuildInformationCommit { - Id: string; - Comment: string; -} - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const environment = getVstsEnvironmentVariables(); - const vstsConnection = createVstsConnection(environment); - - const space = tasks.getInput("Space"); - // @ts-expect-error - const packageIds = getLineSeparatedItems(tasks.getInput("PackageId", true)); - const packageVersion = tasks.getInput("PackageVersion", true); - // @ts-expect-error - const overwriteMode = getOverwriteModeFromReplaceInput(tasks.getInput("Replace", true)); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - const branch = await getBuildBranch(vstsConnection); - const commits = await getBuildChanges(vstsConnection); - - const buildInformation: IOctopusBuildInformation = { - BuildEnvironment: "Azure DevOps", - BuildNumber: environment.buildNumber, - BuildUrl: environment.teamCollectionUri.replace(/\/$/, "") + "/" + environment.projectName + "/_build/results?buildId=" + environment.buildId, - // @ts-expect-error - Branch: branch, - VcsType: getVcsTypeFromProvider(environment.buildRepositoryProvider), - VcsRoot: environment.buildRepositoryUri, - VcsCommitNumber: environment.buildSourceVersion, - // @ts-expect-error - Commits: commits.map((change) => ({ Id: change.id, Comment: change.message })), - }; - - if (!environment.agentBuildDirectory) { - tasks.error("The Build Information step requires build information and therefore is not compatible with use in a Release pipeline."); - return; - } - - const buildInformationDir = path.join(environment.agentBuildDirectory, "octo"); - const buildInformationFile = path.join(buildInformationDir, `${environment.buildId}-buildinformation.json`); - await tasks.mkdirP(buildInformationDir); - await tasks.writeFile(buildInformationFile, JSON.stringify(buildInformation, null, 2)); - - await assertOctoVersionAcceptsIds(); - const octo = await getOrInstallOctoCommandRunner("build-information"); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - const configure: Array<(tool: ToolRunner) => ToolRunner> = [ - connectionArguments(connection), - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - multiArgument(argumentEnquote, "package-id", packageIds), - // @ts-expect-error - argument("version", packageVersion), - argumentEnquote("file", buildInformationFile), - argument("overwrite-mode", overwriteMode), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(build-information;push;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to push build information. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/task.json b/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/task.json deleted file mode 100644 index 3fe3f3fb..00000000 --- a/source/tasksLegacy/OctopusMetadata/OctopusMetadataV4/task.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "id": "b1861ef4-b62e-40c1-bcb0-be00d454a8a7", - "name": "OctopusMetadata", - "friendlyName": "Push Package Build Information to Octopus (legacy)", - "description": "(legacy) There is a later version of this task, we recommend using the latest version. Collect information related to the build, including work items from commit messages, and push to your Octopus Deploy Server.", - "helpMarkDown": "set-by-pack.ps1", - "category": "Package", - "visibility": ["Build"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "pickList", - "label": "Space", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The space within Octopus." - }, - { - "name": "PackageId", - "type": "multiLine", - "label": "Package IDs", - "defaultValue": "", - "required": true, - "helpMarkDown": "Newline-separated package IDs; e.g.\nMyCompany.MyApp\nMyCompany.MyApp2" - }, - { - "name": "PackageVersion", - "type": "string", - "label": "Package Version", - "defaultValue": "", - "required": true, - "helpMarkDown": "The version of the package; must be a valid [SemVer](http://semver.org/) version." - }, - { - "name": "Replace", - "type": "pickList", - "label": "Overwrite Mode", - "defaultValue": "false", - "required": true, - "helpMarkDown": "Normally, if the same package build information already exists on the server, the server will reject the package build information push. This is a good practice as it ensures build information isn't accidentally overwritten or ignored. Use this setting to override this behavior.", - "options": { - "false": "Fail if exists", - "true": "Overwrite existing", - "IgnoreIfExists": "Ignore if exists" - } - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctopusCliBuildInformation) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "Space", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllSpaces", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Push Package Build Information to Octopus (legacy)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Pack/PackV4/icon.png b/source/tasksLegacy/Pack/PackV4/icon.png deleted file mode 100644 index aae79512bdbe636d02f29e0df2ce1e022a9bf14e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XyaRkfT=geE`2YWZ^12tNpM0Nw^1Za4y@GrCjn_XzlJYk&O9__pP)pOyKjn_XNY%KN!@l^rhOoW^09)+pR`;?VM02NMt7JTf6n z?~{m0@HdHz6R(`j`I6Drs>%OxOKOG3TA!SwQ|>pLzvXwk)MWF2S*_rW{dW1jKe!AS Y-Y$}SQ}F9jD$oNAp00i_>zopr03iIossI20 diff --git a/source/tasksLegacy/Pack/PackV4/icon.svg b/source/tasksLegacy/Pack/PackV4/icon.svg deleted file mode 100644 index d9d027bc..00000000 --- a/source/tasksLegacy/Pack/PackV4/icon.svg +++ /dev/null @@ -1 +0,0 @@ -octopus \ No newline at end of file diff --git a/source/tasksLegacy/Pack/PackV4/index.ts b/source/tasksLegacy/Pack/PackV4/index.ts deleted file mode 100644 index 1c5b5135..00000000 --- a/source/tasksLegacy/Pack/PackV4/index.ts +++ /dev/null @@ -1,115 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import * as fs from "fs"; -import { ToolRunner } from "azure-pipelines-task-lib/toolrunner"; -import { getLineSeparatedItems, isNullOrWhitespace, removeTrailingSlashes, safeTrim } from "../../Utils/inputs"; -import { argument, argumentEnquote, argumentIfSet, flag, getOrInstallOctoCommandRunner, includeAdditionalArguments, multiArgument } from "../../Utils/tool"; -import os from "os"; - -export interface PackageRequiredInputs { - packageId: string; - packageFormat: string; -} -export interface PackageOptionalInputs { - packageVersion?: string; - outputPath?: string; - sourcePath?: string; - nuGetAuthor?: string; - nuGetTitle?: string; - nuGetDescription?: string; - nuGetReleaseNotes?: string; - nuGetReleaseNotesFile?: string; - include?: string[]; - listFiles: boolean; - overwrite: boolean; - additionalArguments: string; - compressionLevel: string; -} - -export type PackageInputs = PackageRequiredInputs & PackageOptionalInputs; - -export const configure = (inputs: PackageInputs) => { - return [ - argumentEnquote("id", inputs.packageId), - argument("format", inputs.packageFormat), - // @ts-ignore - argumentIfSet(argument, "version", inputs.packageVersion), - argumentIfSet(argument, "compressionlevel", inputs.compressionLevel), - // @ts-ignore - argumentIfSet(argumentEnquote, "outFolder", inputs.outputPath), - // @ts-ignore - argumentIfSet(argumentEnquote, "basePath", inputs.sourcePath), - // @ts-ignore - argumentIfSet(argumentEnquote, "author", inputs.nuGetAuthor), - // @ts-ignore - argumentIfSet(argumentEnquote, "title", inputs.nuGetTitle), - // @ts-ignore - argumentIfSet(argumentEnquote, "description", inputs.nuGetDescription), - // @ts-ignore - argumentIfSet(argumentEnquote, "releaseNotes", inputs.nuGetReleaseNotes), - argument("overwrite", inputs.overwrite.toString()), - includeAdditionalArguments(inputs.additionalArguments), - (tool: ToolRunner) => { - if (!isNullOrWhitespace(inputs.nuGetReleaseNotesFile) && fs.existsSync(inputs.nuGetReleaseNotesFile) && fs.lstatSync(inputs.nuGetReleaseNotesFile).isFile()) { - console.log(`Release notes file: ${inputs.nuGetReleaseNotesFile}`); - argumentEnquote("releaseNotesFile", inputs.nuGetReleaseNotesFile, tool); - } else { - console.log("No release notes file found"); - } - return tool; - }, - multiArgument(argumentEnquote, "include", inputs.include || []), - flag("verbose", inputs.listFiles), - ]; -}; - -export const getInputs = (): PackageInputs => { - return { - // @ts-ignore - packageId: tasks.getInput("PackageId", true), - // @ts-ignore - packageFormat: tasks.getInput("PackageFormat", true), - packageVersion: tasks.getInput("PackageVersion"), - outputPath: removeTrailingSlashes(safeTrim(tasks.getPathInput("OutputPath"))) || undefined, - sourcePath: removeTrailingSlashes(safeTrim(tasks.getPathInput("SourcePath"))) || undefined, - nuGetAuthor: tasks.getInput("NuGetAuthor"), - nuGetTitle: tasks.getInput("NuGetTitle"), - nuGetDescription: tasks.getInput("NuGetDescription"), - nuGetReleaseNotes: tasks.getInput("NuGetReleaseNotes"), - nuGetReleaseNotesFile: tasks.getInput("NuGetReleaseNotesFile", false), - overwrite: tasks.getBoolInput("Overwrite"), - // @ts-ignore - include: getLineSeparatedItems(tasks.getInput("Include")), - listFiles: tasks.getBoolInput("ListFiles"), - // @ts-ignore - additionalArguments: tasks.getInput("AdditionalArguments"), - // @ts-ignore - compressionLevel: tasks.getInput("CompressionLevel"), - }; -}; - -async function run() { - try { - tasks.warning(`This task is supported, but it no longer actively maintained. -It was originally created for the Octopus CLI when Octopus Deploy only supported NuGet packages. -It is recommended to migrate to the built-in 'Archive Files' task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/archive-files). -Alternatively, if NuGet package metadata is required, consider using the 'NuGet' task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget) or the 'dotnet pack' task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli).`); - - const octo = await getOrInstallOctoCommandRunner("pack"); - const configureTool = configure(getInputs()); - - const code: number = await octo - .map((x) => x.launchOcto(configureTool, "(package;pack;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Pack succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to execute octo pack command. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Pack/PackV4/task.json b/source/tasksLegacy/Pack/PackV4/task.json deleted file mode 100644 index b53988f6..00000000 --- a/source/tasksLegacy/Pack/PackV4/task.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "id": "179fac12-2402-486e-80cf-5a6a8571f7c0", - "name": "OctopusPack", - "friendlyName": "Package Application for Octopus", - "description": "Package your application into a NuPkg or Zip file.", - "helpMarkDown": "set-by-pack.ps1", - "category": "Package", - "visibility": [ - "Build", - "Release" - ], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "nuget", - "displayName": "NuGet", - "isExpanded": false - }, - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "PackageId", - "type": "string", - "label": "Package ID", - "defaultValue": "", - "required": true, - "helpMarkDown": "The ID of the package. e.g. MyCompany.App" - }, - { - "name": "PackageFormat", - "type": "pickList", - "label": "Package Format", - "required": true, - "defaultValue": "NuPkg", - "options": { - "NuPkg": "NuPkg", - "Zip": "Zip" - }, - "helpMarkDown": "Package format. Must be either NuPkg or Zip." - }, - { - "name": "PackageVersion", - "type": "string", - "label": "Package Version", - "defaultValue": "", - "required": false, - "helpMarkDown": "The version of the package; must be a valid [SemVer](http://semver.org/) version; defaults to a timestamp-based version." - }, - { - "name": "SourcePath", - "type": "filePath", - "label": "Source Path", - "defaultValue": "", - "required": false, - "helpMarkDown": "The folder containing the files and folders to package. Defaults to working directory." - }, - { - "name": "OutputPath", - "type": "filePath", - "label": "Output Path", - "defaultValue": "", - "required": false, - "helpMarkDown": "The directory into which the generated package will be written. Defaults to working directory." - }, - { - "name": "NuGetAuthor", - "type": "string", - "label": "Author", - "defaultValue": "", - "required": false, - "helpMarkDown": "Add an author to the NuGet package metadata.", - "groupName": "nuget" - }, - { - "name": "NuGetTitle", - "type": "string", - "label": "Title", - "defaultValue": "", - "required": false, - "helpMarkDown": "Add a title to the NuGet package metadata.", - "groupName": "nuget" - }, - { - "name": "NuGetDescription", - "type": "string", - "label": "Description", - "defaultValue": "", - "required": false, - "helpMarkDown": "Add a description to the NuGet package metadata.", - "groupName": "nuget" - }, - { - "name": "NuGetReleaseNotes", - "type": "string", - "label": "Release Notes", - "defaultValue": "", - "required": false, - "helpMarkDown": "Add release notes to the NuGet package metadata.", - "groupName": "nuget" - }, - { - "name": "NuGetReleaseNotesFile", - "type": "filePath", - "label": "Release Notes File", - "defaultValue": "", - "required": false, - "helpMarkDown": "A file containing release notes to be added to the NuGet package metadata.", - "groupName": "nuget" - }, - { - "name": "Include", - "type": "multiLine", - "label": "Include", - "defaultValue": "", - "required": false, - "helpMarkDown": "File patterns to include, relative to the root path. e.g. /bin/*.dll", - "groupName": "advanced" - }, - { - "name": "Overwrite", - "type": "boolean", - "label": "Overwrite", - "defaultValue": "false", - "required": false, - "helpMarkDown": "Allow an existing package of the same ID and version to be overwritten.", - "groupName": "advanced" - }, - { - "name": "ListFiles", - "type": "boolean", - "label": "Log Added Files", - "defaultValue": "false", - "required": "false", - "helpMarkDown": "Write a list of all files added to the build log.", - "groupName": "advanced" - }, - { - "name": "CompressionLevel", - "type": "pickList", - "label": "Compression Level", - "defaultValue": "optimal", - "required": false, - "helpMarkDown": "Set the compression level.", - "groupName": "advanced", - "options": { - "none": "None", - "fast": "Fast", - "optimal": "Optimal" - } - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctopusCliPack) for available parameters.", - "groupName": "advanced" - } - ], - "instanceNameFormat": "Package $(PackageId)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Promote/PromoteV3/icon.png b/source/tasksLegacy/Promote/PromoteV3/icon.png deleted file mode 100644 index 0f1c1a7aa10ce39e27a6d85e44c9f440914e3bc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 621 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XCI|S0xav=SAgyQr|NsB#C*LQpdto!{k#@r&857S>KmK|y zeA0F3-RURaYxlg-s@f5@{8_=)S9-nI6#WW6e)_DMI6=WZec#=$H(vkL$Xzo1b}US(G$pd5Hfjc=L##jy>z%tgnYz3J z2NpRo>s)V?YEWLZ;`OdahfT62*MFLx$MT>h>?*^SmarLDUNro<%d|b2ovV_m`W=Iw z&IFw|535(4XDH;idAP#gDsbDS1DjVr&YASISyzs~qmGYv#aiP6A-f5Vm1zd$pR10X znSbc4ac6UkDRfqa6 z=_HXVv(wc_)&`|aseii93Ax|&iGyn5Pmw#V> d{ZBA~f%lnJ$_HM<-@veE@O1TaS?83{1ONl5HsSyP diff --git a/source/tasksLegacy/Promote/PromoteV3/icon.svg b/source/tasksLegacy/Promote/PromoteV3/icon.svg deleted file mode 100644 index 94905963..00000000 --- a/source/tasksLegacy/Promote/PromoteV3/icon.svg +++ /dev/null @@ -1 +0,0 @@ -octopus \ No newline at end of file diff --git a/source/tasksLegacy/Promote/PromoteV3/index.ts b/source/tasksLegacy/Promote/PromoteV3/index.ts deleted file mode 100644 index 53b5eb44..00000000 --- a/source/tasksLegacy/Promote/PromoteV3/index.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { multiArgument, connectionArguments, includeAdditionalArgumentsAndProxyConfig, flag, argumentEnquote, argumentIfSet, getOrInstallOctoCommandRunner } from "../../Utils/tool"; -import { getOptionalCsvInput, getRequiredCsvInput } from "../../Utils/inputs"; -import { getDefaultOctopusConnectionDetailsOrThrow, resolveProjectName } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - // @ts-expect-error - const project = await resolveProjectName(connection, tasks.getInput("Project", true)).then((x) => x.value); - - const from = tasks.getInput("From", true); - const to = getRequiredCsvInput("To"); - const showProgress = tasks.getBoolInput("ShowProgress"); - const deploymentForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTentantTags"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - const octo = await getOrInstallOctoCommandRunner("promote-release"); - - const configure = [ - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - argumentEnquote("project", project), - connectionArguments(connection), - // @ts-expect-error - argumentEnquote("from", from), - multiArgument(argumentEnquote, "to", to), - multiArgument(argumentEnquote, "tenant", deploymentForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - flag("progress", showProgress), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(release;promote;v3)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded promoting release with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to promote release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Promote/PromoteV3/task.json b/source/tasksLegacy/Promote/PromoteV3/task.json deleted file mode 100644 index 83b24410..00000000 --- a/source/tasksLegacy/Promote/PromoteV3/task.json +++ /dev/null @@ -1,173 +0,0 @@ -{ - "id": "1627fcfe-f292-4904-adac-26cfb14bdb07", - "name": "OctopusPromote", - "friendlyName": "Promote Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Promote an Octopus release from one environment to another", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 3, - "Minor": 1, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "string", - "label": "Space (Legacy - Use version 4 of this task)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "False" - }, - "helpMarkDown": "Version 3 of this task has limited support for spaces. We recommend using version 4 of this task for a better experience." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "Project", - "type": "pickList", - "label": "Project", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Octopus Deploy Project Name" - }, - { - "name": "From", - "type": "pickList", - "label": "Promote From", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The environment the release is currently deployed to. e.g. 'Staging'" - }, - { - "name": "To", - "type": "pickList", - "label": "Promote To", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Comma separated list of environments to deploy to" - }, - { - "name": "ShowProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "False", - "required": false, - "helpMarkDown": "If checked, the build process will only succeed if the deployment is successful." - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Promote the release for this comma delimited list of tenants. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant Tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Promote the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExePromoteRelease) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroups", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Project", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroup", - "parameters": { - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "From", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllEnvironments", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "To", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllEnvironments", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllTenants", - "resultTemplate": "{\"Value\":\"{{{Name}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Promote $(Project) from $(From) to $(To)", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Promote/PromoteV4/icon.png b/source/tasksLegacy/Promote/PromoteV4/icon.png deleted file mode 100644 index 0f1c1a7aa10ce39e27a6d85e44c9f440914e3bc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 621 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XCI|S0xav=SAgyQr|NsB#C*LQpdto!{k#@r&857S>KmK|y zeA0F3-RURaYxlg-s@f5@{8_=)S9-nI6#WW6e)_DMI6=WZec#=$H(vkL$Xzo1b}US(G$pd5Hfjc=L##jy>z%tgnYz3J z2NpRo>s)V?YEWLZ;`OdahfT62*MFLx$MT>h>?*^SmarLDUNro<%d|b2ovV_m`W=Iw z&IFw|535(4XDH;idAP#gDsbDS1DjVr&YASISyzs~qmGYv#aiP6A-f5Vm1zd$pR10X znSbc4ac6UkDRfqa6 z=_HXVv(wc_)&`|aseii93Ax|&iGyn5Pmw#V> d{ZBA~f%lnJ$_HM<-@veE@O1TaS?83{1ONl5HsSyP diff --git a/source/tasksLegacy/Promote/PromoteV4/icon.svg b/source/tasksLegacy/Promote/PromoteV4/icon.svg deleted file mode 100644 index 94905963..00000000 --- a/source/tasksLegacy/Promote/PromoteV4/icon.svg +++ /dev/null @@ -1 +0,0 @@ -octopus \ No newline at end of file diff --git a/source/tasksLegacy/Promote/PromoteV4/index.ts b/source/tasksLegacy/Promote/PromoteV4/index.ts deleted file mode 100644 index 672fc0bd..00000000 --- a/source/tasksLegacy/Promote/PromoteV4/index.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { argumentEnquote, argumentIfSet, assertOctoVersionAcceptsIds, connectionArguments, flag, getOrInstallOctoCommandRunner, includeAdditionalArgumentsAndProxyConfig, multiArgument } from "../../Utils/tool"; -import { getOptionalCsvInput, getRequiredCsvInput } from "../../Utils/inputs"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - const project = tasks.getInput("Project", true); - const from = tasks.getInput("From", true); - const to = getRequiredCsvInput("To"); - const deployForTenants = getOptionalCsvInput("DeployForTenants"); - const deployForTenantTags = getOptionalCsvInput("DeployForTenantTags"); - const showProgress = tasks.getBoolInput("ShowProgress"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - await assertOctoVersionAcceptsIds(); - const octo = await getOrInstallOctoCommandRunner("promote-release"); - - const configure = [ - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - // @ts-expect-error - argumentEnquote("project", project), - connectionArguments(connection), - // @ts-expect-error - argumentEnquote("from", from), - multiArgument(argumentEnquote, "to", to), - multiArgument(argumentEnquote, "tenant", deployForTenants), - multiArgument(argumentEnquote, "tenanttag", deployForTenantTags), - flag("progress", showProgress), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(release;promote;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded promoting release with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to promote release. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Promote/PromoteV4/task.json b/source/tasksLegacy/Promote/PromoteV4/task.json deleted file mode 100644 index d29b100f..00000000 --- a/source/tasksLegacy/Promote/PromoteV4/task.json +++ /dev/null @@ -1,195 +0,0 @@ -{ - "id": "1627fcfe-f292-4904-adac-26cfb14bdb07", - "name": "OctopusPromote", - "friendlyName": "Promote Octopus Release", - "description": "There is a later version of this task, we recommend using the latest version. Promote an Octopus release from one environment to another", - "helpMarkDown": "set-by-pack.ps1", - "category": "Deploy", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "tenant", - "displayName": "Tenants", - "isExpanded": false - }, - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "pickList", - "label": "Space", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The space within Octopus." - }, - { - "name": "ProjectGroup", - "type": "pickList", - "label": "Project Group", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project group within Octopus (this populates the next Project dropdown)." - }, - { - "name": "Project", - "type": "pickList", - "label": "Project", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The project within Octopus." - }, - { - "name": "From", - "type": "pickList", - "label": "Promote From", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The environment the release is currently deployed to. e.g. 'Staging'" - }, - { - "name": "To", - "type": "pickList", - "label": "Promote To", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Comma separated list of environments to deploy to" - }, - { - "name": "ShowProgress", - "type": "boolean", - "label": "Show Deployment Progress", - "defaultValue": "False", - "required": false, - "helpMarkDown": "If checked, the build process will only succeed if the deployment is successful." - }, - { - "name": "DeployForTenants", - "type": "pickList", - "label": "Tenant(s)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "Promote the release for this comma delimited list of tenants. Wildcard '*' will deploy to all tenants currently able to deploy to the above provided environment.", - "groupName": "tenant" - }, - { - "name": "DeployForTenantTags", - "type": "string", - "label": "Tenant Tag(s)", - "defaultValue": "", - "required": false, - "helpMarkDown": "Promote the release for tenants who match these tags and are ready to deploy to the provided environment.", - "groupName": "tenant" - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExePromoteRelease) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "Space", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllSpaces", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "ProjectGroup", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllProjectGroupsInSpace", - "parameters": { - "SpaceId": "$(Space)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "Project", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusListProjectsInProjectGroupInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectGroupId": "$(ProjectGroup)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "From", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectEnvironmentsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectId": "$(Project)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "To", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectEnvironmentsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectId": "$(Project)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - }, - { - "target": "DeployForTenants", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusProjectTenantsInSpace", - "parameters": { - "SpaceId": "$(Space)", - "ProjectName": "$(Project)" - }, - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Promote Project in Octopus", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Push/PushV3/icon.png b/source/tasksLegacy/Push/PushV3/icon.png deleted file mode 100644 index 236566a308c71c4b35ce91fa54e6914d05fb8d7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 481 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X5(0ceT=geE`2YXEw4QzPx)(OH9^H8T^V5&NwR_$iJAMB2 zlkd|{z7JdeY{`X>D>rQ4clWDC?vm|$4|^_rGX3O-f~~JMUjO{`<8KR(@UBDe9zA_7 zW8(Sr({J6jGn&@kn#Jq<8&?5MzN-Gj8RWW>AirQB7aw4ViIIK_RQuY~#WAGf)|JUO zg_;dGToq^cx@BK|*Zu$hbk@acQL?{p++$Bya%U26DRcg?yrHafN@ijhgZ4r1rD>cV z3NIEYFVJzex!AERaEc521I41Md6xGQ)F%rjx;bztnH<-Cb9A{1o6Eh}1U819ca*nG zm+fZUxZM1v#PO~^%`NJJE-iDIgrXGHTDTmJtv%Q9TK0{={z`MZhK=0Z+>-MIj5Y|y z9A0xm?Mgz*b=ND;xTpNT7s&dg{Nhgm$)%1_;l&3Qg-X3%IeF*&R+q&G0y|G#y{PkN zL&dCBCvNy}vz?b_|L$w;kE+Gn%0G$!U$dQonSt+$*N$DY75)Id&EVoctopus \ No newline at end of file diff --git a/source/tasksLegacy/Push/PushV3/index.ts b/source/tasksLegacy/Push/PushV3/index.ts deleted file mode 100644 index e002e3a0..00000000 --- a/source/tasksLegacy/Push/PushV3/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; - -import { multiArgument, connectionArguments, includeAdditionalArgumentsAndProxyConfig, flag, argumentEnquote, argumentIfSet, getOrInstallOctoCommandRunner } from "../../Utils/tool"; -import { getLineSeparatedItems, resolveGlobs } from "../../Utils/inputs"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - // @ts-expect-error - const packages = getLineSeparatedItems(tasks.getInput("Package", true)); - const replace = tasks.getBoolInput("Replace"); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - const octo = await getOrInstallOctoCommandRunner("push"); - const matchedPackages = await resolveGlobs(packages); - - const configure = [ - connectionArguments(connection), - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - multiArgument(argumentEnquote, "package", matchedPackages), - flag("replace-existing", replace), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(package;push;v3)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to push package. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Push/PushV3/task.json b/source/tasksLegacy/Push/PushV3/task.json deleted file mode 100644 index 5d6384ad..00000000 --- a/source/tasksLegacy/Push/PushV3/task.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "id": "d05ad9a2-5d9e-4a1c-a887-14034334d6f2", - "name": "OctopusPush", - "friendlyName": "Push Package(s) to Octopus", - "description": "There is a later version of this task, we recommend using the latest version. Push your NuGet or Zip package to your Octopus Deploy Server", - "helpMarkDown": "set-by-pack.ps1", - "category": "Package", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 3, - "Minor": 1, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "string", - "label": "Space (Legacy - Use version 4 of this task)", - "defaultValue": "", - "required": false, - "properties": { - "EditableOptions": "False" - }, - "helpMarkDown": "Version 3 of this task has limited support for spaces. We recommend using version 4 of this task for a better experience." - }, - { - "name": "Package", - "type": "multiLine", - "label": "Package", - "defaultValue": "", - "required": true, - "helpMarkDown": "Package file to push. To push multiple packages, enter on multiple lines." - }, - { - "name": "Replace", - "type": "boolean", - "label": "Replace Existing", - "defaultValue": "False", - "required": true, - "helpMarkDown": "If the package already exists in the repository, the default behavior is to reject the new package being pushed. Set this flag to 'True' to overwrite the existing package." - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExePush) for available parameters.", - "groupName": "advanced" - } - ], - "instanceNameFormat": "Push Packages to Octopus", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Push/PushV4/icon.png b/source/tasksLegacy/Push/PushV4/icon.png deleted file mode 100644 index 236566a308c71c4b35ce91fa54e6914d05fb8d7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 481 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X5(0ceT=geE`2YXEw4QzPx)(OH9^H8T^V5&NwR_$iJAMB2 zlkd|{z7JdeY{`X>D>rQ4clWDC?vm|$4|^_rGX3O-f~~JMUjO{`<8KR(@UBDe9zA_7 zW8(Sr({J6jGn&@kn#Jq<8&?5MzN-Gj8RWW>AirQB7aw4ViIIK_RQuY~#WAGf)|JUO zg_;dGToq^cx@BK|*Zu$hbk@acQL?{p++$Bya%U26DRcg?yrHafN@ijhgZ4r1rD>cV z3NIEYFVJzex!AERaEc521I41Md6xGQ)F%rjx;bztnH<-Cb9A{1o6Eh}1U819ca*nG zm+fZUxZM1v#PO~^%`NJJE-iDIgrXGHTDTmJtv%Q9TK0{={z`MZhK=0Z+>-MIj5Y|y z9A0xm?Mgz*b=ND;xTpNT7s&dg{Nhgm$)%1_;l&3Qg-X3%IeF*&R+q&G0y|G#y{PkN zL&dCBCvNy}vz?b_|L$w;kE+Gn%0G$!U$dQonSt+$*N$DY75)Id&EVoctopus \ No newline at end of file diff --git a/source/tasksLegacy/Push/PushV4/index.ts b/source/tasksLegacy/Push/PushV4/index.ts deleted file mode 100644 index bd8d0671..00000000 --- a/source/tasksLegacy/Push/PushV4/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; - -import { getLineSeparatedItems, getOverwriteModeFromReplaceInput, resolveGlobs } from "../../Utils/inputs"; -import { argument, argumentEnquote, argumentIfSet, assertOctoVersionAcceptsIds, connectionArguments, getOrInstallOctoCommandRunner, includeAdditionalArgumentsAndProxyConfig, multiArgument } from "../../Utils/tool"; -import { getDefaultOctopusConnectionDetailsOrThrow } from "../../Utils/connection"; -import os from "os"; - -async function run() { - try { - tasks.warning("There is a later version of this task, we recommend using the latest version."); - const connection = getDefaultOctopusConnectionDetailsOrThrow(); - - const space = tasks.getInput("Space"); - // @ts-expect-error - const packages = getLineSeparatedItems(tasks.getInput("Package", true)); - // @ts-expect-error - const overwriteMode = getOverwriteModeFromReplaceInput(tasks.getInput("Replace", true)); - const additionalArguments = tasks.getInput("AdditionalArguments"); - - await assertOctoVersionAcceptsIds(); - const octo = await getOrInstallOctoCommandRunner("push"); - const matchedPackages = await resolveGlobs(packages); - - const configure = [ - connectionArguments(connection), - // @ts-expect-error - argumentIfSet(argumentEnquote, "space", space), - multiArgument(argumentEnquote, "package", matchedPackages), - argument("overwrite-mode", overwriteMode), - // @ts-expect-error - includeAdditionalArgumentsAndProxyConfig(connection.url, additionalArguments), - ]; - - const code: number = await octo - .map((x) => x.launchOcto(configure, "(package;push;v4)")) - .getOrElseL((x) => { - throw new Error(x); - }); - - tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code); - } catch (error: unknown) { - if (error instanceof Error) { - tasks.setResult(tasks.TaskResult.Failed, `"Failed to push package. ${error.message}${os.EOL}${error.stack}`, true); - } - } -} - -run(); diff --git a/source/tasksLegacy/Push/PushV4/task.json b/source/tasksLegacy/Push/PushV4/task.json deleted file mode 100644 index f9aceb43..00000000 --- a/source/tasksLegacy/Push/PushV4/task.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "id": "d05ad9a2-5d9e-4a1c-a887-14034334d6f2", - "name": "OctopusPush", - "friendlyName": "Push Package(s) to Octopus", - "description": "There is a later version of this task, we recommend using the latest version. Push your NuGet or Zip package to your Octopus Deploy Server", - "helpMarkDown": "set-by-pack.ps1", - "category": "Package", - "visibility": ["Build", "Release"], - "author": "Octopus Deploy", - "version": { - "Major": 4, - "Minor": 3, - "Patch": 0 - }, - "demands": [], - "minimumAgentVersion": "2.144.0", - "groups": [ - { - "name": "advanced", - "displayName": "Advanced Options", - "isExpanded": false - } - ], - "inputs": [ - { - "name": "OctoConnectedServiceName", - "type": "connectedService:OctopusEndpoint", - "label": "Octopus Deploy Server", - "defaultValue": "", - "required": true, - "helpMarkDown": "Octopus Deploy server connection" - }, - { - "name": "Space", - "type": "pickList", - "label": "Space", - "defaultValue": "", - "required": true, - "properties": { - "EditableOptions": "True" - }, - "helpMarkDown": "The space within Octopus." - }, - { - "name": "Package", - "type": "multiLine", - "label": "Package", - "defaultValue": "", - "required": true, - "helpMarkDown": "Package file to push. To push multiple packages, enter on multiple lines." - }, - { - "name": "Replace", - "type": "pickList", - "label": "Overwrite Mode", - "defaultValue": "false", - "required": true, - "helpMarkDown": "Normally, if the same package already exists on the server, the server will reject the package push. This is a good practice as it ensures a package isn't accidentally overwritten or ignored. Use this setting to override this behavior.", - "options": { - "false": "Fail if exists", - "true": "Overwrite existing", - "IgnoreIfExists": "Ignore if exists" - } - }, - { - "name": "AdditionalArguments", - "type": "string", - "label": "Additional Arguments", - "defaultValue": "", - "required": false, - "helpMarkDown": "Additional arguments to be supplied to the Octopus CLI. See the [Octopus CLI documentation](https://g.octopushq.com/OctoExePush) for available parameters.", - "groupName": "advanced" - } - ], - "dataSourceBindings": [ - { - "target": "Space", - "endpointId": "$(OctoConnectedServiceName)", - "dataSourceName": "OctopusAllSpaces", - "resultTemplate": "{\"Value\":\"{{{Id}}}\",\"DisplayValue\":\"{{{Name}}}\"}" - } - ], - "instanceNameFormat": "Push Packages to Octopus", - "execution": { - "Node10": { - "target": "index.js" - } - } -} diff --git a/source/tasksLegacy/Utils/OctoApiKeyHandler.ts b/source/tasksLegacy/Utils/OctoApiKeyHandler.ts deleted file mode 100644 index 64d7f4c9..00000000 --- a/source/tasksLegacy/Utils/OctoApiKeyHandler.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import { IRequestHandler, IHttpClientResponse } from "typed-rest-client/Interfaces"; -import * as http from "http"; - -export class OctoApiKeyHandler implements IRequestHandler { - key: string; - - constructor(key: string) { - this.key = key; - } - - prepareRequest(options: http.RequestOptions): void { - // @ts-expect-error - options.headers["X-Octopus-ApiKey"] = this.key; - } - - canHandleAuthentication(): boolean { - return false; - } - - handleAuthentication(): Promise { - throw "This handler does not handle authentication."; - } -} - -export default OctoApiKeyHandler; diff --git a/source/tasksLegacy/Utils/connection.ts b/source/tasksLegacy/Utils/connection.ts deleted file mode 100644 index 54234a33..00000000 --- a/source/tasksLegacy/Utils/connection.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as tasks from "azure-pipelines-task-lib/task"; -import { RestClient } from "typed-rest-client/RestClient"; -import { getDefaultOctoConnectionInputValue } from "./inputs"; -import { either } from "fp-ts"; -import OctoApiKeyHandler from "./OctoApiKeyHandler"; - -export interface OctoServerConnectionDetails { - url: string; - apiKey: string; - ignoreSslErrors: boolean; -} - -export function getDefaultOctopusConnectionDetailsOrThrow() { - const result = getDefaultOctoConnectionInputValue().map(getOctopusConnectionDetails).toNullable(); - if (!result) { - throw new Error("Could not retrieve default Octo connection information"); - } - return result; -} - -export function getOctopusConnectionDetails(name: string): OctoServerConnectionDetails { - const octoEndpointAuthorization = tasks.getEndpointAuthorization(name, false); - const ignoreSSL = tasks.getEndpointDataParameter(name, "ignoreSslErrors", true); - return { - // @ts-expect-error - url: tasks.getEndpointUrl(name, false), - // @ts-expect-error - apiKey: octoEndpointAuthorization.parameters["apitoken"], - ignoreSslErrors: !!ignoreSSL && ignoreSSL.toLowerCase() === "true", - }; -} - -export function fetchProjectName(details: OctoServerConnectionDetails, projectId: string) { - console.log("Ignore SSL: " + details.ignoreSslErrors); - const client = new RestClient("OctoTFS", details.url, [new OctoApiKeyHandler(details.apiKey)], { ignoreSslError: details.ignoreSslErrors }); - return client - .get<{ Name: string }>(`api/projects/${projectId}`) - .then((x) => { - if (x.result) { - return either.right(x.result.Name); - } - - return either.left(`Could not resolve project name given id "${projectId}". Server returned status code: ${x.statusCode}`); - }) - .catch((error) => either.left(error)); -} - -export const isProjectId = (projectNameOrId: string) => /\w*Projects-\d*/.test(projectNameOrId); - -export function resolveProjectName(connection: OctoServerConnectionDetails, projectNameOrId: string) { - if (isProjectId(projectNameOrId)) { - return fetchProjectName(connection, projectNameOrId); - } - - return Promise.resolve(either.right(projectNameOrId)); -} diff --git a/source/tasksLegacy/Utils/environment.ts b/source/tasksLegacy/Utils/environment.ts deleted file mode 100644 index fdf704d5..00000000 --- a/source/tasksLegacy/Utils/environment.ts +++ /dev/null @@ -1,243 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import * as path from "path"; -import { v4 as uuidv4 } from "uuid"; -import * as vsts from "azure-devops-node-api/WebApi"; -import * as wit from "azure-devops-node-api/interfaces/WorkItemTrackingInterfaces"; -import * as bi from "azure-devops-node-api/interfaces/BuildInterfaces"; -import * as tasks from "azure-pipelines-task-lib"; -import { isNullOrWhitespace } from "./inputs"; - -export interface ReleaseEnvironmentVariables { - releaseName: string; - releaseId: string; - releaseUri: string; -} - -export interface BuildEnvironmentVariables { - buildNumber: string; - buildId: number; - buildName: string; - buildRepositoryName: string; - buildRepositoryProvider: string; - buildRepositoryUri: string; - buildSourceVersion: string; -} - -export interface AgentEnvironmentVariables { - agentBuildDirectory: string; -} - -export interface SystemEnvironmentVariables { - projectName: string; - projectId: string; - teamCollectionUri: string; - defaultWorkingDirectory: string; -} - -export type VstsEnvironmentVariables = ReleaseEnvironmentVariables & BuildEnvironmentVariables & AgentEnvironmentVariables & SystemEnvironmentVariables; - -export const getVstsEnvironmentVariables = (): VstsEnvironmentVariables => { - return { - projectId: process.env["SYSTEM_TEAMPROJECTID"] || "", - projectName: process.env["SYSTEM_TEAMPROJECT"] || "", - buildNumber: process.env["BUILD_BUILDNUMBER"] || "", - buildId: Number(process.env["BUILD_BUILDID"]), - buildName: process.env["BUILD_DEFINITIONNAME"] || "", - buildRepositoryName: process.env["BUILD_REPOSITORY_NAME"] || "", - releaseName: process.env["RELEASE_RELEASENAME"] || "", - releaseUri: process.env["RELEASE_RELEASEWEBURL"] || "", - releaseId: process.env["RELEASE_RELEASEID"] || "", - teamCollectionUri: process.env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"] || "", - defaultWorkingDirectory: process.env["SYSTEM_DEFAULTWORKINGDIRECTORY"] || "", - buildRepositoryProvider: process.env["BUILD_REPOSITORY_PROVIDER"] || "", - buildRepositoryUri: process.env["BUILD_REPOSITORY_URI"] || "", - buildSourceVersion: process.env["BUILD_SOURCEVERSION"] || "", - agentBuildDirectory: process.env["AGENT_BUILDDIRECTORY"] || "", - }; -}; - -export const generateReleaseNotesContent = (environment: VstsEnvironmentVariables, linkedItemReleaseNote: string, customReleaseNotes: string) => { - let notes = "Release created by "; - const buildUri = `${environment.teamCollectionUri}${encodeURIComponent(environment.projectName)}/_build/index?_a=summary&buildId=${environment.buildId}`; - - if (!isNullOrWhitespace(environment.releaseId)) { - notes += `Release Management Release [${environment.releaseName} #${environment.releaseId}](${environment.releaseUri}) `; - } - - if (environment.buildId) { - notes += `Build [${environment.buildName} #${environment.buildNumber}](${buildUri}) from the ${environment.buildRepositoryName} repository `; - } - - notes += `in Team Project ${environment.projectName}`; - if (!isNullOrWhitespace(linkedItemReleaseNote)) { - notes += `\r\n\r\n${linkedItemReleaseNote}`; - } - - if (!isNullOrWhitespace(customReleaseNotes)) { - notes += `\r\n\r\n**Custom Notes:**`; - notes += `\r\n\r\n${customReleaseNotes}`; - } - - return notes; -}; - -export const createReleaseNotesFile = (content: () => string, directory: string): string => { - const filePath = path.join(directory, `release-notes-${uuidv4()}.md`); - tasks.writeFile(filePath, content(), { encoding: "utf8" }); - return filePath; -}; - -export const getWorkItemState = (workItem: wit.WorkItem) => { - return `${workItem && workItem.fields ? workItem.fields["System.State"] : ""}`; -}; - -export const getWorkItemTags = (workItem: wit.WorkItem) => { - if (workItem && workItem.fields && !isNullOrWhitespace(workItem.fields["System.Tags"])) { - const tags = workItem.fields["System.Tags"].split(";"); - return tags.reduce((prev: string, current: string) => { - return (prev += `${current}`); - }, ""); - } - - return ""; -}; - -export const getLinkedReleaseNotes = async (client: vsts.WebApi, includeComments: boolean, includeWorkItems: boolean) => { - const environment = getVstsEnvironmentVariables(); - console.log(`Environment = ${environment.buildRepositoryProvider}`); - console.log(`Comments = ${includeComments}, WorkItems = ${includeWorkItems}`); - - try { - const changes = await client.getBuildApi().then((x) => x.getBuildChanges(environment.projectName, environment.buildId)); - - let releaseNotes = ""; - const newLine = "\r\n\r\n"; - - if (includeComments) { - if (environment.buildRepositoryProvider === "TfsVersionControl") { - console.log("Adding changeset comments to release notes"); - releaseNotes += changes.reduce((prev, current) => { - // @ts-expect-error - return prev + `* [${current.id} - ${current.author.displayName}](${getChangesetUrl(environment, current.location)}): ${current.message}${newLine}`; - }, `**Changeset Comments:**${newLine}`); - } else if (environment.buildRepositoryProvider === "TfsGit") { - /* - TfsGit repo has a known URL that individual commits can be linked to, - so the release notes have markdown URLs - */ - console.log("Adding commit message to release notes"); - releaseNotes += changes.reduce((prev, current) => { - // @ts-expect-error - return prev + `* [${current.id} - ${current.author.displayName}](${getCommitUrl(environment, current)}): ${current.message}${newLine}`; - }, `**Commit Messages:**${newLine}`); - } else { - /* - This could be any other git repo like Git, GitHub, SVN etc. We don't know - how to link to the commits here, so leave out the URLs. - */ - console.log("Adding commit message to release notes"); - releaseNotes += changes.reduce((prev, current) => { - // @ts-expect-error - return prev + `* ${current.id} - ${current.author.displayName}: ${current.message}${newLine}`; - }, `**Commit Messages:**${newLine}`); - } - } - - if (includeWorkItems) { - console.log("adding work items to release notes"); - releaseNotes += `**Work Items:**${newLine}`; - - const workItemRefs = await client.getBuildApi().then((x) => x.getBuildWorkItemsRefs(environment.projectName, environment.buildId)); - - if (workItemRefs.length > 0) { - const workItems = await client.getWorkItemTrackingApi().then((x) => x.getWorkItems(workItemRefs.map((x) => Number(x.id)))); - - const workItemEditBaseUri = `${environment.teamCollectionUri}${environment.projectId}/_workitems/edit`; - releaseNotes += workItems.reduce((prev, current) => { - // @ts-expect-error - return (prev += `* [${current.id}](${workItemEditBaseUri}/${current.id}): ${current.fields["System.Title"]} ${getWorkItemState(current)} ${getWorkItemTags(current)} ${newLine}`); - }, ""); - } - } - - console.log(`Release notes:\r\n${releaseNotes}`); - return releaseNotes; - } catch (ex) { - console.log("An exception was thrown while building the release notes."); - console.log(ex); - console.log("See https://github.com/OctopusDeploy/OctoTFS/issues/107 for more details."); - console.log("The release notes will be empty."); - return ""; - } -}; - -const getChangesetUrl = (environment: VstsEnvironmentVariables, apiUrl: string) => { - const workItemId = apiUrl.substr(apiUrl.lastIndexOf("/") + 1); - return `${environment.teamCollectionUri}${environment.projectId}/_versionControl/changeset/${workItemId}`; -}; - -const getCommitUrl = (environment: VstsEnvironmentVariables, change: bi.Change) => { - const commitId = change.id; - // @ts-expect-error - const segments = change.location.split("/"); - const repositoryId = segments[segments.length - 3]; - return `${environment.teamCollectionUri}${environment.projectId}/_git/${repositoryId}/commit/${commitId}`; -}; - -export const createVstsConnection = (environment: SystemEnvironmentVariables) => { - const vstsAuthorization = tasks.getEndpointAuthorization("SystemVssConnection", true); - // @ts-expect-error - const token = vstsAuthorization.parameters["AccessToken"]; - const authHandler = vsts.getPersonalAccessTokenHandler(token); - return new vsts.WebApi(environment.teamCollectionUri, authHandler); -}; - -export const getVcsTypeFromProvider = (buildRepositoryProvider: string) => { - switch (buildRepositoryProvider) { - case "TfsGit": - case "GitHub": - return "Git"; - case "TfsVersionControl": - return "TFVC"; - default: - return buildRepositoryProvider; - } -}; - -export const getBuildBranch = async (client: vsts.WebApi) => { - const environment = getVstsEnvironmentVariables(); - const api = await client.getBuildApi(); - return (await api.getBuild(environment.projectName, environment.buildId)).sourceBranch; -}; - -export const getBuildChanges = async (client: vsts.WebApi) => { - const environment = getVstsEnvironmentVariables(); - const api = await client.getBuildApi(); - const gitApi = await client.getGitApi(); - - const changes = await api.getBuildChanges(environment.projectName, environment.buildId, undefined, 100000); - - if (environment.buildRepositoryProvider === "TfsGit") { - const promises = changes.map(async (x) => { - if (x.messageTruncated) { - // @ts-expect-error - const segments = x.location.split("/"); - const repositoryId = segments[segments.length - 3]; - - try { - // @ts-expect-error - const commit = await gitApi.getCommit(x.id, repositoryId); - x.message = commit.comment; - } catch (err) { - tasks.warning(`Using a truncated commit message for commit ${x.id}, because an error occurred while fetching the full message. ${err}`); - } - } - - return x; - }); - - await Promise.all(promises); - } - - return changes; -}; diff --git a/source/tasksLegacy/Utils/inputs.ts b/source/tasksLegacy/Utils/inputs.ts deleted file mode 100644 index ac8cb1b5..00000000 --- a/source/tasksLegacy/Utils/inputs.ts +++ /dev/null @@ -1,74 +0,0 @@ -import * as tasks from "azure-pipelines-task-lib/task"; -import { option } from "fp-ts"; -import glob from "glob"; -import { flatten } from "ramda"; - -export enum ReplaceOverwriteMode { - false = "FailIfExists", - true = "OverwriteExisting", - IgnoreIfExists = "IgnoreIfExists", -} - -export function getOverwriteModeFromReplaceInput(replace: string): ReplaceOverwriteMode { - return ReplaceOverwriteMode[replace as keyof typeof ReplaceOverwriteMode] || ReplaceOverwriteMode.false; -} - -export const DefaultOctoConnectionInputName = "OctoConnectedServiceName"; - -export const pGlobNoNull = (pattern: string): Promise => { - return new Promise((resolve, reject) => { - glob(pattern, { nonull: true }, (err, matches) => { - if (err) { - reject(err); - return; - } - resolve(matches); - }); - }); -}; - -export function isNullOrWhitespace(value: string | null | undefined): value is null | undefined { - return !value || !/\S/.test(value); -} - -export function safeTrim(value: string | null | undefined): string | null | undefined { - return value ? value.trim() : value; -} - -export function removeTrailingSlashes(value: string | null | undefined): string | null | undefined { - return value ? value.replace(/[/\\]+(?=\s*)$/, "") : value; -} - -export function getLineSeparatedItems(value: string): Array { - return value ? value.split(/[\r\n]+/g).map((x) => x.trim()) : []; -} - -const getRequiredInput = (name: string) => { - return option.fromNullable(tasks.getInput(name, true)); -}; - -const splitComma = (x: string) => x.split(",").map((x) => x.trim()); - -const getOptionalInput = (name: string) => { - return option.fromNullable(tasks.getInput(name, false)); -}; - -export const getOptionalCsvInput = (name: string) => { - return getOptionalInput(name).map(splitComma).getOrElse([]); -}; - -export const getRequiredCsvInput = (name: string) => { - return getRequiredInput(name).map(splitComma).getOrElse([]); -}; - -export { getRequiredInput, getOptionalInput }; - -export function getDefaultOctoConnectionInputValue() { - return getRequiredInput(DefaultOctoConnectionInputName); -} - -export const resolveGlobs = (globs: string[]): Promise => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - return Promise.all(globs.map(pGlobNoNull)).then((x) => flatten(x)); -}; diff --git a/source/tasksLegacy/Utils/install.ts b/source/tasksLegacy/Utils/install.ts deleted file mode 100644 index 2c2e00ef..00000000 --- a/source/tasksLegacy/Utils/install.ts +++ /dev/null @@ -1,192 +0,0 @@ -import * as path from "path"; -import * as fs from "fs"; -import * as tasks from "azure-pipelines-task-lib/task"; -import * as tools from "azure-pipelines-tool-lib/tool"; -import * as TypedRestClient from "typed-rest-client/RestClient"; -import { head, filter } from "ramda"; -import { IProxyConfiguration } from "typed-rest-client/Interfaces"; -import { ToolName, ToolNameBeforeV7 } from "./tool"; - -interface LatestResponse { - latest: string; - downloads: DownloadOption[]; -} - -type DownloadOption = { - version: string; - template: string; - location: string; - extension: string; - platform?: string; - architecture?: string; -}; - -type Primitive = undefined | null | boolean | number | string; - -interface Dictionary { - [key: string]: Primitive; -} - -const RestClient = TypedRestClient.RestClient; -const OctopurlsUrl = "https://g.octopushq.com"; - -const applyTemplate = (dictionary: Dictionary, template: string) => { - return Object.keys(dictionary).reduce((result, key) => result.replace(new RegExp(`{${key}}`, "g"), dictionary[key] ? String(dictionary[key]) : ""), template); -}; - -const isPortableDownloadOption = (option: DownloadOption) => { - return option.platform === "portable" && option.extension === ".zip"; -}; - -const filterPortableDownload = (options: DownloadOption[]) => head(filter(isPortableDownloadOption, options)); - -const extract = (archivePath: string) => { - return tools.extractZip(archivePath); -}; - -function getExecutableExtension(): string { - return ".dll"; -} - -function getLocalTool(version: string): string { - console.log("Checking local tool cache"); - return tools.findLocalTool(ToolName, version) || tools.findLocalTool(ToolNameBeforeV7, version); -} - -function findOcto(rootFolder: string) { - const octoPath = [path.join(rootFolder, "*" + ToolName + getExecutableExtension()), path.join(rootFolder, "*" + ToolNameBeforeV7 + getExecutableExtension())]; - console.log(`Looking for ${octoPath}`); - const allPaths = tasks.find(rootFolder); - const matches = tasks.match(allPaths, octoPath, rootFolder); - return matches[0]; -} - -async function getOrDownloadOcto(option: DownloadOption, download?: (option: DownloadOption) => Promise, extractTool = true): Promise { - let cachedToolPath = getLocalTool(option.version); - - if (!cachedToolPath) { - try { - console.log("Attempting to download the Octopus CLI tool"); - const downloadPath = await (download !== undefined && download != null ? download(option) : tools.downloadTool(option.location)); - const toolPath = extractTool ? await extract(downloadPath) : downloadPath; - - tools.debug(`Adding ${ToolName} ${option.version} to cache`); - tasks.writeFile(path.join(toolPath, `${ToolName}.cmd`), `dotnet "%~dp0/${ToolName}.dll" %*`); - cachedToolPath = await tools.cacheDir(toolPath, ToolName, option.version); - } catch (exception) { - throw new Error(`Failed to download Octopus CLI tool version ${option.version}. ${exception}`); - } - } - - const octoPath = findOcto(cachedToolPath); - if (!octoPath) { - throw new Error("The Octopus CLI tool wasn't found in tools directory"); - } - - tools.debug(`Found ${ToolName} at ${octoPath}`); - - fs.chmodSync(octoPath, "777"); - - tools.debug(`chmod for ${octoPath} applied`); - - return octoPath; -} - -async function resolvePublishedOctoVersion(version?: string): Promise { - if (!version) { - version = "latest"; - } - console.log(`Attempting to contact ${OctopurlsUrl} to find Octopus CLI tool version ${version}`); - - const proxyConfiguration = tasks.getHttpProxyConfiguration(OctopurlsUrl); - let proxySettings: IProxyConfiguration | undefined = undefined; - - if (proxyConfiguration) { - console.log( - "Using agent configured proxy. If this command should not be sent via the agent's proxy, you might need to add or modify the agent's .proxybypass file. See https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/proxy#specify-proxy-bypass-urls." - ); - proxySettings = { - proxyUrl: proxyConfiguration.proxyUrl, - proxyUsername: proxyConfiguration.proxyUsername, - proxyPassword: proxyConfiguration.proxyPassword, - proxyBypassHosts: proxyConfiguration.proxyBypassHosts, - }; - } - - const octopurls = new RestClient("OctoTFS/Tasks", OctopurlsUrl, undefined, { proxy: proxySettings }); - - const response = await octopurls.get("LatestTools"); - - if (response.result === null || response.result === undefined) { - throw Error(`Failed to resolve Octopus CLI tool version ${version}. Endpoint returned status code ${response.statusCode})`); - } - - const option = filterPortableDownload(response.result.downloads); - - if (option === null || option === undefined) { - throw Error(`Failed to resolve the Octopus CLI tool portable download location. The result did not contain the download location.`); - } - - if (version === "latest" || version === response.result.latest) { - return option; - } - - //Adjust the version and location to point to the specified version - const result = { ...option, version }; - result.location = applyTemplate(result, result.template); - - return result; -} - -function addToolToPath(toolPath: string) { - if (!process.env["PATH"]?.startsWith(path.dirname(toolPath))) { - tools.debug(`Adding ${ToolName} to path`); - tools.prependPath(path.dirname(toolPath)); - } - - return toolPath; -} - -async function getEmbeddedOcto(folderPath: string): Promise { - const versionPath = path.join(folderPath, "version.json"); - const option = JSON.parse(await readFile(versionPath)); - const tempDirectory = getAgentTempDirectory(); - - tasks.cp(folderPath, tempDirectory, "-rf"); - - if (!option) { - throw "Could not resolve the original download location of the embedded Octopus CLI tool."; - } - - console.log(`Using the embedded Octopus CLI tool (version ${option.version}).`); - - return getOrDownloadOcto( - option, - () => { - return new Promise((resolve) => resolve(path.join(tempDirectory, path.basename(folderPath), "bin"))); - }, - false - ); -} - -async function readFile(path: string, encoding: BufferEncoding = "utf8"): Promise { - return new Promise((resolve, reject) => { - fs.readFile(path, { encoding: encoding }, (err, data) => { - if (err) { - reject(err); - } else { - resolve(data); - } - }); - }); -} - -function getAgentTempDirectory() { - const tempDirectory = tasks.getVariable("Agent.TempDirectory"); - if (!tempDirectory) { - throw new Error("Agent.TempDirectory is not set"); - } - return tempDirectory; -} - -export { resolvePublishedOctoVersion, getOrDownloadOcto, addToolToPath, getEmbeddedOcto }; diff --git a/source/tasksLegacy/Utils/tool.ts b/source/tasksLegacy/Utils/tool.ts deleted file mode 100644 index e892e3e7..00000000 --- a/source/tasksLegacy/Utils/tool.ts +++ /dev/null @@ -1,174 +0,0 @@ -import * as tasks from "azure-pipelines-task-lib/task"; -import { ToolRunner, IExecSyncResult, IExecOptions } from "azure-pipelines-task-lib/toolrunner"; -import { OctoServerConnectionDetails } from "./connection"; -import { curry } from "ramda"; -import { isNullOrWhitespace } from "./inputs"; -import { Option, some, none } from "fp-ts/lib/Option"; -import { Either, right, fromOption } from "fp-ts/lib/Either"; -import { getOrDownloadOcto, addToolToPath, resolvePublishedOctoVersion } from "./install"; - -export const ToolName = "octo"; -export const ToolNameBeforeV7 = "Octo"; - -export interface ArgFormatter { - (name: string, value: string, tool: ToolRunner): ToolRunner; -} - -function stringOption(value?: string): Option { - return isNullOrWhitespace(value) ? none : some(value); -} - -export class OctoLauncher { - runner: ToolRunner; - - constructor(runner: ToolRunner) { - this.runner = runner; - } - - private getExecOptions(stepIdentifier: string): IExecOptions { - return { env: { OCTOEXTENSION: `${process.env.EXTENSION_VERSION} ${stepIdentifier}`, ...process.env } }; - } - - public launchOcto(configurations: Array<(tool: ToolRunner) => ToolRunner>, stepIdentifier: string): Q.Promise { - configureTool(configurations)(this.runner); - - return this.runner.exec(this.getExecOptions(stepIdentifier)); - } - - public launchOctoSync(configurations: Array<(tool: ToolRunner) => ToolRunner>, stepIdentifier: string): IExecSyncResult { - configureTool(configurations)(this.runner); - - return this.runner.execSync(this.getExecOptions(stepIdentifier)); - } -} - -export async function getOrInstallOctoCommandRunner(command: string): Promise> { - //If we can't find octo then it hasn't been added as an installer task - //or it hasn't been added to the path. - const octo = getOctoCommandRunner(command); - if (octo.isSome()) { - return right(new OctoLauncher(octo.value)); - } - - return resolvePublishedOctoVersion("latest") - .then(getOrDownloadOcto) - .catch((err) => { - tasks.error(err); - throw Error("Unable to locate and download the latest Octopus CLI tool. To use the embedded copy" + " or another specific version, add the Octopus CLI installer task to the build pipeline" + " before this task."); - }) - .then(addToolToPath) - .then(() => getOctoCommandRunner(command).map((x) => new OctoLauncher(x))) - .then(fromOption("Unable to run the Octopus CLI tool.")); -} - -export function getOctoCommandRunner(command: string): Option { - const isWindows = /windows/i.test(tasks.osType()); - if (isWindows) { - return stringOption(tasks.which(`${ToolName}`, false) || tasks.which(`${ToolNameBeforeV7}`, false)) - .map(tasks.tool) - .map((x) => x.arg(command)); - } - - return getPortableOctoCommandRunner(command); -} - -export function getPortableOctoCommandRunner(command: string): Option { - const octo = stringOption(tasks.which(`${ToolName}.dll`, false) || tasks.which(`${ToolNameBeforeV7}.dll`, false)); - const dotnet = tasks.which("dotnet", false); - - if (isNullOrWhitespace(dotnet)) { - tasks.warning("dotnet runtime was not found and this task will most likely fail. Target an agent which has the appropriate capability or add a DotNet core installer task to the start of you build definition to fix this problem."); - } - - const tool = tasks.tool(tasks.which("dotnet", true)); - - const result = octo.map((x) => tool.arg(`${x}`).arg(command)); - - return result; -} - -export const assertOctoVersionAcceptsIds = async function (): Promise { - const octo = await getOrInstallOctoCommandRunner("version"); - const result = octo - .map((x) => x.launchOctoSync([], "version")) - .getOrElseL((x) => { - throw new Error(x); - }); - - const outputLastLine = result.stdout.trim().split(/\r?\n/).pop() || ""; - const [, major, minor, patch] = outputLastLine.trim().match(/^(\d+)\.(\d+)\.(\d+)\b/) || [0, 0, 0, 0]; - const compatible = - `${major}.${minor}.${patch}` == "1.0.0" || // allow dev versions - major > 6 || - (major == 6 && minor > 10) || - (major == 6 && minor == 10 && patch >= 0); - if (!compatible) { - throw new Error("The Octopus CLI tool is too old to run this task. Please use version 6.10.0 or newer, or downgrade the task to version 3.*."); - } -}; - -export const connectionArguments = curry(({ url, apiKey, ignoreSslErrors }: OctoServerConnectionDetails, tool: ToolRunner) => { - let tr = tool.arg(`--server=${url}`).arg(`--apiKey=${apiKey}`); - if (ignoreSslErrors) { - tr = tr.arg(`--ignoreSslErrors`); - } - return tr; -}); - -export const multiArgument = curry((arg: ArgFormatter, name: string, values: string[], tool: ToolRunner) => { - values.forEach((value) => arg(name, value, tool)); - return tool; -}); - -export const argument = curry((name: string, value: string | null | undefined, tool: ToolRunner) => { - return tool.line(`--${name}=${value}`); -}); - -export const argumentEnquote = curry((name: string, value: string | null | undefined, tool: ToolRunner) => { - return argument(name, `"${value}"`, tool); -}); - -export const includeAdditionalArgumentsAndProxyConfig = curry((url: string, value: string, tool: ToolRunner) => { - const proxyRegex = /-proxy=/; - - const proxyConfig = tasks.getHttpProxyConfiguration(url); - - if (proxyConfig) { - if (!proxyRegex.test(value)) { - console.log( - "Using agent configured proxy. If this command should not be sent via the agent's proxy, you might need to add or modify the agent's .proxybypass file. See https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/proxy#specify-proxy-bypass-urls." - ); - argument("proxy", proxyConfig.proxyUrl, tool); - if (proxyConfig.proxyUsername) { - argument("proxyUser", proxyConfig.proxyUsername, tool); - } - if (proxyConfig.proxyPassword) { - argument("proxyPass", proxyConfig.proxyPassword, tool); - } - } - } - - return includeAdditionalArguments(value, tool); -}); - -export const includeAdditionalArguments = curry((value: string, tool: ToolRunner) => { - return tool.line(value); -}); - -export const configureTool = curry((configurations: Array<(tool: ToolRunner) => ToolRunner>, tool: ToolRunner) => { - configurations.forEach((x) => x(tool)); - return tool; -}); - -export const flag = curry((name: string, value: boolean, tool: ToolRunner) => { - return value ? tool.arg(`--${name}`) : tool; -}); - -export const argumentIf = curry((predicate: (value: string | null | undefined) => boolean, arg: ArgFormatter, name: string, value: string | null | undefined, tool: ToolRunner): ToolRunner => { - if (predicate(value)) { - return arg(name, value || "", tool); - } - return tool; -}); - -export const argumentIfSet = argumentIf((val) => !isNullOrWhitespace(val));