From 50da50e806bf00fdd986327b3e682a43c12ab5ec Mon Sep 17 00:00:00 2001 From: Sumiran Aggarwal Date: Wed, 4 Dec 2019 13:38:39 +0530 Subject: [PATCH 1/3] cleanup --- .../AzureRmWebAppDeploymentProvider.ts | 37 ++++++++++--------- .../BuiltInLinuxWebAppDeploymentProvider.ts | 11 +++--- .../WindowsWebAppRunFromZipProvider.ts | 28 ++++++++------ .../WindowsWebAppWarDeployProvider.ts | 4 +- .../WindowsWebAppZipDeployProvider.ts | 13 ++++--- Tasks/AzureWebAppV1/task.json | 2 +- Tasks/AzureWebAppV1/task.loc.json | 2 +- 7 files changed, 55 insertions(+), 42 deletions(-) diff --git a/Tasks/AzureWebAppV1/deploymentProvider/AzureRmWebAppDeploymentProvider.ts b/Tasks/AzureWebAppV1/deploymentProvider/AzureRmWebAppDeploymentProvider.ts index 95445595cee4..f8fe61f4b7bc 100644 --- a/Tasks/AzureWebAppV1/deploymentProvider/AzureRmWebAppDeploymentProvider.ts +++ b/Tasks/AzureWebAppV1/deploymentProvider/AzureRmWebAppDeploymentProvider.ts @@ -1,17 +1,21 @@ -import { IWebAppDeploymentProvider } from './IWebAppDeploymentProvider'; -import { TaskParameters } from '../taskparameters'; -import { KuduServiceUtility } from 'azurermdeploycommon/operations/KuduServiceUtility'; +import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility' + import { AzureAppService } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service'; -import { Kudu } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service-kudu'; import { AzureAppServiceUtility } from 'azurermdeploycommon/operations/AzureAppServiceUtility'; -import tl = require('azure-pipelines-task-lib/task'); -import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility' -import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility'; -import { PackageUtility } from 'azurermdeploycommon/webdeployment-common/packageUtility'; import { AzureDeployPackageArtifactAlias } from 'azurermdeploycommon/Constants'; +import { AzureEndpoint } from 'azurermdeploycommon/azure-arm-rest/azureModels'; import { AzureRmEndpointAuthenticationScheme } from 'azurermdeploycommon/azure-arm-rest/constants'; +import { IWebAppDeploymentProvider } from './IWebAppDeploymentProvider'; +import { Kudu } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service-kudu'; +import { KuduServiceUtility } from 'azurermdeploycommon/operations/KuduServiceUtility'; +import { PackageUtility } from 'azurermdeploycommon/webdeployment-common/packageUtility'; +import { TaskParameters } from '../taskparameters'; +import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility'; + +import tl = require('azure-pipelines-task-lib/task'); + import publishProfileUtility = require("utility-common-v2/publishProfileUtility"); -import { AzureEndpoint } from 'azurermdeploycommon/azure-arm-rest/azureModels'; + export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvider { protected taskParams:TaskParameters; @@ -22,7 +26,6 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide protected virtualApplicationPath: string = ""; protected activeDeploymentID; protected publishProfileScmCredentials: publishProfileUtility.ScmCredentials; - protected isPublishProfileAuthSchemeEndpoint: boolean = false; protected slotName; constructor(taskParams: TaskParameters) { @@ -34,7 +37,6 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide public async PreDeploymentStep() { if (this.taskParams.azureEndpoint.scheme && this.taskParams.azureEndpoint.scheme.toLowerCase() === AzureRmEndpointAuthenticationScheme.PublishProfile) { let publishProfileEndpoint: AzureEndpoint = this.taskParams.azureEndpoint; - this.isPublishProfileAuthSchemeEndpoint = true; this.publishProfileScmCredentials = await publishProfileUtility.getSCMCredentialsFromPublishProfile(publishProfileEndpoint.PublishProfile); this.kuduService = new Kudu(this.publishProfileScmCredentials.scmUri, this.publishProfileScmCredentials.username, this.publishProfileScmCredentials.password); let resourceId = publishProfileEndpoint.resourceId; @@ -55,16 +57,17 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide public async DeployWebAppStep() {} public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) { - if(this.kuduServiceUtility) { - if (!this.isPublishProfileAuthSchemeEndpoint) { - await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess); - } + if(!!this.appService) { + await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess); + } + + if(!!this.kuduServiceUtility) { this.activeDeploymentID = await this.kuduServiceUtility.updateDeploymentStatus(isDeploymentSuccess, null, {'type': 'Deployment', slotName: this.slotName}); tl.debug('Active DeploymentId :'+ this.activeDeploymentID); } let appServiceApplicationUrl: string; - if (this.isPublishProfileAuthSchemeEndpoint) { + if (!!this.appServiceUtility) { appServiceApplicationUrl = await this.appServiceUtility.getApplicationURL(); } else { appServiceApplicationUrl = this.publishProfileScmCredentials.applicationUrl; @@ -74,7 +77,7 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide } protected async PostDeploymentStep() { - if (!this.isPublishProfileAuthSchemeEndpoint) { + if (!!this.appServiceUtility) { if(this.taskParams.AppSettings) { var customApplicationSettings = ParameterParser.parse(this.taskParams.AppSettings); await this.appServiceUtility.updateAndMonitorAppSettings(customApplicationSettings); diff --git a/Tasks/AzureWebAppV1/deploymentProvider/BuiltInLinuxWebAppDeploymentProvider.ts b/Tasks/AzureWebAppV1/deploymentProvider/BuiltInLinuxWebAppDeploymentProvider.ts index d2ab3a2ef0eb..6541633c9a15 100644 --- a/Tasks/AzureWebAppV1/deploymentProvider/BuiltInLinuxWebAppDeploymentProvider.ts +++ b/Tasks/AzureWebAppV1/deploymentProvider/BuiltInLinuxWebAppDeploymentProvider.ts @@ -1,8 +1,10 @@ -import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; -import tl = require('azure-pipelines-task-lib/task'); import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility' + +import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility'; +import tl = require('azure-pipelines-task-lib/task'); + var webCommonUtility = require('azurermdeploycommon/webdeployment-common/utility.js'); var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js'); var zipUtility = require('azurermdeploycommon/webdeployment-common/ziputility.js'); @@ -60,12 +62,11 @@ export class BuiltInLinuxWebAppDeploymentProvider extends AzureRmWebAppDeploymen } public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) { + await super.UpdateDeploymentStatus(isDeploymentSuccess); if(this.kuduServiceUtility) { if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) { await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID); - } - - await super.UpdateDeploymentStatus(isDeploymentSuccess); + } } } } \ No newline at end of file diff --git a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppRunFromZipProvider.ts b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppRunFromZipProvider.ts index ea8f71915cbf..db09e9fa0bc6 100644 --- a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppRunFromZipProvider.ts +++ b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppRunFromZipProvider.ts @@ -1,10 +1,13 @@ -import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; -import tl = require('azure-pipelines-task-lib/task'); import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility' + +import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; import { DeploymentType } from '../taskparameters'; +import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js'; import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility'; import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility'; -import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js'; + +import tl = require('azure-pipelines-task-lib/task'); + var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js'); var zipUtility = require('azurermdeploycommon/webdeployment-common/ziputility.js'); @@ -35,8 +38,8 @@ export class WindowsWebAppRunFromZipProvider extends AzureRmWebAppDeploymentProv tl.debug("Compressed folder into zip " + webPackage); } - tl.debug("Initiated deployment via kudu service for webapp package : "); - if (!this.isPublishProfileAuthSchemeEndpoint) { + tl.debug("Initiated deployment via kudu service for webapp package : " + webPackage); + if (!!this.appServiceUtility) { var addCustomApplicationSetting = ParameterParser.parse(runFromZipAppSetting); var deleteCustomApplicationSetting = ParameterParser.parse(oldRunFromZipAppSetting); var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(addCustomApplicationSetting, deleteCustomApplicationSetting); @@ -55,14 +58,17 @@ export class WindowsWebAppRunFromZipProvider extends AzureRmWebAppDeploymentProv } public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) { - if (this.isPublishProfileAuthSchemeEndpoint) { - await super.UpdateDeploymentStatus(isDeploymentSuccess); - } else { + if(!!this.appService) { await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess); + } - let appServiceApplicationUrl: string = await this.appServiceUtility.getApplicationURL(); - console.log(tl.loc('AppServiceApplicationURL', appServiceApplicationUrl)); - tl.setVariable('AppServiceApplicationUrl', appServiceApplicationUrl); + let appServiceApplicationUrl: string; + if (!!this.appServiceUtility) { + appServiceApplicationUrl = await this.appServiceUtility.getApplicationURL(); + } else { + appServiceApplicationUrl = this.publishProfileScmCredentials.applicationUrl; } + console.log(tl.loc('AppServiceApplicationURL', appServiceApplicationUrl)); + tl.setVariable('AppServiceApplicationUrl', appServiceApplicationUrl); } } \ No newline at end of file diff --git a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppWarDeployProvider.ts b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppWarDeployProvider.ts index 6fb6792eaa7d..1bdac545a83c 100644 --- a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppWarDeployProvider.ts +++ b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppWarDeployProvider.ts @@ -1,8 +1,8 @@ import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; + import tl = require('azure-pipelines-task-lib/task'); var webCommonUtility = require('azurermdeploycommon/webdeployment-common/utility.js'); - export class WindowsWebAppWarDeployProvider extends AzureRmWebAppDeploymentProvider { private zipDeploymentID: string; @@ -25,8 +25,8 @@ export class WindowsWebAppWarDeployProvider extends AzureRmWebAppDeploymentProvi } public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) { + await super.UpdateDeploymentStatus(isDeploymentSuccess); if(this.kuduServiceUtility) { - await super.UpdateDeploymentStatus(isDeploymentSuccess); if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) { await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID); } diff --git a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppZipDeployProvider.ts b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppZipDeployProvider.ts index ca69528f9cbc..f5052995f687 100644 --- a/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppZipDeployProvider.ts +++ b/Tasks/AzureWebAppV1/deploymentProvider/WindowsWebAppZipDeployProvider.ts @@ -1,9 +1,12 @@ -import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; -import tl = require('azure-pipelines-task-lib/task'); import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility' + +import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider'; import { DeploymentType } from '../taskparameters'; -import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility'; import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js'; +import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility'; + +import tl = require('azure-pipelines-task-lib/task'); + const deleteOldRunFromZipAppSetting: string = '-WEBSITE_RUN_FROM_ZIP'; const removeRunFromZipAppSetting: string = '-WEBSITE_RUN_FROM_PACKAGE 0'; var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js'); @@ -36,7 +39,7 @@ export class WindowsWebAppZipDeployProvider extends AzureRmWebAppDeploymentProvi } tl.debug("Initiated deployment via kudu service for webapp package : "); - if (!this.isPublishProfileAuthSchemeEndpoint) { + if (!!this.appServiceUtility) { var updateApplicationSetting = ParameterParser.parse(removeRunFromZipAppSetting) var deleteApplicationSetting = ParameterParser.parse(deleteOldRunFromZipAppSetting) var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(updateApplicationSetting, deleteApplicationSetting); @@ -54,8 +57,8 @@ export class WindowsWebAppZipDeployProvider extends AzureRmWebAppDeploymentProvi } public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) { + await super.UpdateDeploymentStatus(isDeploymentSuccess); if(this.kuduServiceUtility) { - await super.UpdateDeploymentStatus(isDeploymentSuccess); if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) { await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID); } diff --git a/Tasks/AzureWebAppV1/task.json b/Tasks/AzureWebAppV1/task.json index 6b1e26f0fc73..6cdefc9c88c3 100644 --- a/Tasks/AzureWebAppV1/task.json +++ b/Tasks/AzureWebAppV1/task.json @@ -18,7 +18,7 @@ "version": { "Major": 1, "Minor": 159, - "Patch": 4 + "Patch": 5 }, "minimumAgentVersion": "2.104.1", "groups": [ diff --git a/Tasks/AzureWebAppV1/task.loc.json b/Tasks/AzureWebAppV1/task.loc.json index 019e0085e086..36168ecb5183 100644 --- a/Tasks/AzureWebAppV1/task.loc.json +++ b/Tasks/AzureWebAppV1/task.loc.json @@ -18,7 +18,7 @@ "version": { "Major": 1, "Minor": 159, - "Patch": 4 + "Patch": 5 }, "minimumAgentVersion": "2.104.1", "groups": [ From b82a31a49c0657cf5ca5346675d07a25c1a94fab Mon Sep 17 00:00:00 2001 From: Sumiran Aggarwal Date: Wed, 4 Dec 2019 14:11:14 +0530 Subject: [PATCH 2/3] reverting change --- Tasks/AzureWebAppV1/package-lock.json | 8 +++--- .../yamlvariablesubstitutionutility.ts | 27 ------------------- 2 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 Tasks/Common/webdeployment-common-v2/yamlvariablesubstitutionutility.ts diff --git a/Tasks/AzureWebAppV1/package-lock.json b/Tasks/AzureWebAppV1/package-lock.json index 6c110c08b707..cc5fc46d2b89 100644 --- a/Tasks/AzureWebAppV1/package-lock.json +++ b/Tasks/AzureWebAppV1/package-lock.json @@ -380,12 +380,12 @@ }, "isemail": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz", "integrity": "sha1-vgPfjMPineTSxd9lASY/H6RZXpo=" }, "joi": { "version": "6.10.1", - "resolved": "http://registry.npmjs.org/joi/-/joi-6.10.1.tgz", + "resolved": "https://registry.npmjs.org/joi/-/joi-6.10.1.tgz", "integrity": "sha1-TVDDGAeRIgAP5fFq8f+OGRe3fgY=", "requires": { "hoek": "2.x.x", @@ -454,7 +454,7 @@ }, "ltx": { "version": "2.6.2", - "resolved": "http://registry.npmjs.org/ltx/-/ltx-2.6.2.tgz", + "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.6.2.tgz", "integrity": "sha1-cD5EN9XjlNJsAxT9j9Xevtjgmdk=", "requires": { "inherits": "^2.0.1" @@ -641,7 +641,7 @@ }, "tunnel": { "version": "0.0.4", - "resolved": "http://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", "integrity": "sha1-LTeFoVjBdMmhbcLARuxfxfF0IhM=" }, "typed-rest-client": { diff --git a/Tasks/Common/webdeployment-common-v2/yamlvariablesubstitutionutility.ts b/Tasks/Common/webdeployment-common-v2/yamlvariablesubstitutionutility.ts deleted file mode 100644 index b0c6b0f41009..000000000000 --- a/Tasks/Common/webdeployment-common-v2/yamlvariablesubstitutionutility.ts +++ /dev/null @@ -1,27 +0,0 @@ -var yaml = require('js-yaml'); -var fs = require('fs'); -import tl = require('azure-pipelines-task-lib/task'); - -export function yamlVariableSubstitution(folderPath: string, yamlFiles) { - let variableTree = createEnvTree(tl.getVariables()); - let isSubstitutionApplied: boolean = false; - for(let yamlFile of yamlFiles) { - console.log(tl.loc('JSONvariableSubstitution' , yamlFile)); - var matchFiles = utility.findfiles(path.join(folderPath, yamlFile)); - if(matchFiles.length === 0) { - throw new Error(tl.loc('NoYAMLfilematchedwithspecificpattern', yamlFile)); - } - for(let file of matchFiles) { - let yamlObject; - try { - yamlObject = yaml.safeLoad(fs.readFileSync(file, 'utf8')); - } - catch(exception) { - throw Error(tl.loc('JSONParseError', file, exception)); - } - console.log(tl.loc('JSONvariableSubstitution' , file)); - isSubstitutionApplied = substituteVariables(yamlObject, variableTree) || isSubstitutionApplied; - tl.writeFile(file, yaml.safeDump(yamlObject), 'utf8'); - } - } -} \ No newline at end of file From 472c3c074ff128b847b82e3cdf19257d0b1c888e Mon Sep 17 00:00:00 2001 From: Sumiran Aggarwal Date: Wed, 4 Dec 2019 14:12:55 +0530 Subject: [PATCH 3/3] revert package lock changes --- Tasks/AzureWebAppV1/package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/AzureWebAppV1/package-lock.json b/Tasks/AzureWebAppV1/package-lock.json index cc5fc46d2b89..7084233de27b 100644 --- a/Tasks/AzureWebAppV1/package-lock.json +++ b/Tasks/AzureWebAppV1/package-lock.json @@ -284,7 +284,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "requires": { "core-util-is": "~1.0.0",