diff --git a/Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts b/Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts index 460e7360ceb1..eda0db747ef0 100644 --- a/Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts +++ b/Tasks/AzureRmWebAppDeployment/azurermwebappdeployment.ts @@ -27,7 +27,7 @@ async function main() { tl.setResourcePath(path.join( __dirname, 'task.json')); var taskParams: TaskParameters = TaskParametersUtility.getParameters(); var azureEndpoint: AzureEndpoint = await new AzureRMEndpoint(taskParams.connectedServiceName).getEndpoint(); - + var virtualApplicationPath: string; console.log(tl.loc('GotconnectiondetailsforazureRMWebApp0', taskParams.WebAppName)); if(!taskParams.DeployToSlotFlag) { taskParams.ResourceGroupName = await AzureResourceFilterUtility.getResourceGroupName(azureEndpoint, taskParams.WebAppName); @@ -71,6 +71,7 @@ async function main() { if(taskParams.VirtualApplication) { physicalPath = await appServiceUtility.getPhysicalPath(taskParams.VirtualApplication); await kuduServiceUtility.createPathIfRequired(physicalPath); + virtualApplicationPath = physicalPath; } webPackage = await FileTransformsUtility.applyTransformations(webPackage, taskParams); @@ -112,7 +113,7 @@ async function main() { } if(taskParams.ScriptType) { - await kuduServiceUtility.runPostDeploymentScript(taskParams); + await kuduServiceUtility.runPostDeploymentScript(taskParams, virtualApplicationPath); } await appServiceUtility.updateScmTypeAndConfigurationDetails(); diff --git a/Tasks/AzureRmWebAppDeployment/operations/KuduServiceUtility.ts b/Tasks/AzureRmWebAppDeployment/operations/KuduServiceUtility.ts index 62ea06eeba72..f6a244986a09 100644 --- a/Tasks/AzureRmWebAppDeployment/operations/KuduServiceUtility.ts +++ b/Tasks/AzureRmWebAppDeployment/operations/KuduServiceUtility.ts @@ -34,23 +34,25 @@ export class KuduServiceUtility { } } - public async runPostDeploymentScript(taskParams: TaskParameters): Promise { + public async runPostDeploymentScript(taskParams: TaskParameters, directoryPath?: string): Promise { try { + directoryPath = (!!directoryPath) ? directoryPath : physicalRootPath.substring(1); + if(taskParams.TakeAppOfflineFlag) { - await this._appOfflineKuduService(physicalRootPath, true); + await this._appOfflineKuduService(directoryPath, true); } var scriptFile = this._getPostDeploymentScript(taskParams.ScriptType, taskParams.InlineScript, taskParams.ScriptPath, taskParams.isLinuxApp); var uniqueID = this.getDeploymentID(); var fileExtension : string = taskParams.isLinuxApp ? '.sh' : '.cmd'; var mainCmdFilePath = path.join(__dirname, '..', 'postDeploymentScript', 'mainCmdFile' + fileExtension); - await this._appServiceKuduService.uploadFile(physicalRootPath, 'mainCmdFile_' + uniqueID + fileExtension, mainCmdFilePath); - await this._appServiceKuduService.uploadFile(physicalRootPath, 'kuduPostDeploymentScript_' + uniqueID + fileExtension, scriptFile.filePath); + await this._appServiceKuduService.uploadFile(directoryPath, 'mainCmdFile_' + uniqueID + fileExtension, mainCmdFilePath); + await this._appServiceKuduService.uploadFile(directoryPath, 'kuduPostDeploymentScript_' + uniqueID + fileExtension, scriptFile.filePath); console.log(tl.loc('ExecuteScriptOnKudu')); - await this.runCommand('site\\wwwroot', + await this.runCommand(directoryPath, 'mainCmdFile_' + uniqueID + fileExtension + ' ' + uniqueID, 30, 'script_result_' + uniqueID + '.txt'); - await this._printPostDeploymentLogs(physicalRootPath, uniqueID); + await this._printPostDeploymentLogs(directoryPath, uniqueID); } catch(error) { @@ -58,14 +60,14 @@ export class KuduServiceUtility { } finally { try { - await this._appServiceKuduService.uploadFile(physicalRootPath, 'delete_log_file_' + uniqueID + fileExtension, path.join(__dirname, '..', 'postDeploymentScript', 'deleteLogFile' + fileExtension)); - await this.runCommand('site\\wwwroot', 'delete_log_file_' + uniqueID + fileExtension + ' ' + uniqueID, 0, null); + await this._appServiceKuduService.uploadFile(directoryPath, 'delete_log_file_' + uniqueID + fileExtension, path.join(__dirname, '..', 'postDeploymentScript', 'deleteLogFile' + fileExtension)); + await this.runCommand(directoryPath, 'delete_log_file_' + uniqueID + fileExtension + ' ' + uniqueID, 0, null); } catch(error) { tl.debug('Unable to delete log files : ' + error); } if(taskParams.TakeAppOfflineFlag) { - await this._appOfflineKuduService(physicalRootPath, false); + await this._appOfflineKuduService(directoryPath, false); } } } diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index b7759180eec2..3037de424690 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -16,7 +16,7 @@ "version": { "Major": 3, "Minor": 3, - "Patch": 38 + "Patch": 39 }, "releaseNotes": "What's new in Version 3.0:
  Supports File Transformations (XDT)
  Supports Variable Substitutions(XML, JSON)
Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.", "minimumAgentVersion": "2.104.1", diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index 82cf7a3b5c5c..c976f5cd95db 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -16,7 +16,7 @@ "version": { "Major": 3, "Minor": 3, - "Patch": 38 + "Patch": 39 }, "releaseNotes": "ms-resource:loc.releaseNotes", "minimumAgentVersion": "2.104.1",