diff --git a/Tasks/AzureResourceGroupDeploymentV2/operations/ResourceGroup.ts b/Tasks/AzureResourceGroupDeploymentV2/operations/ResourceGroup.ts index efd1f1bb36b3..f4456c7455a3 100644 --- a/Tasks/AzureResourceGroupDeploymentV2/operations/ResourceGroup.ts +++ b/Tasks/AzureResourceGroupDeploymentV2/operations/ResourceGroup.ts @@ -278,7 +278,7 @@ export class ResourceGroup { private createDeploymentName(): string { var name: string; if (this.taskParameters.templateLocation == "Linked artifact") { - name = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.taskParameters.csmFile)[0]; + name = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(this.taskParameters.csmFile))[0]; } else { name = this.taskParameters.csmFileLink; } @@ -382,7 +382,7 @@ export class ResourceGroup { private getDeploymentDataForLinkedArtifact(): Deployment { var template: TemplateObject; - var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.taskParameters.csmFile); + var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(this.taskParameters.csmFile)); if (fileMatches.length > 1) { throw new Error(tl.loc("TemplateFilePatternMatchingMoreThanOneFile", fileMatches)); } @@ -405,7 +405,7 @@ export class ResourceGroup { var parameters: Map = {} as Map; if (utils.isNonEmpty(this.taskParameters.csmParametersFile)) { - var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.taskParameters.csmParametersFile); + var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(this.taskParameters.csmParametersFile)); if (fileMatches.length > 1) { throw new Error(tl.loc("TemplateParameterFilePatternMatchingMoreThanOneFile", fileMatches)); } @@ -569,6 +569,10 @@ export class ResourceGroup { await this.performAzureDeployment(armClient, deployment, 3); } + private escapeBlockCharacters(str: string): string { + return str.replace(/[\[]/g, '$&[]'); + } + private enablePrereqDG = "ConfigureVMWithDGAgent"; private enablePrereqWinRM = "ConfigureVMwithWinRM"; private enablePrereqNone = "None"; diff --git a/Tasks/AzureResourceGroupDeploymentV2/task.json b/Tasks/AzureResourceGroupDeploymentV2/task.json index 4e6ff31fa6b7..feb2c86235a3 100644 --- a/Tasks/AzureResourceGroupDeploymentV2/task.json +++ b/Tasks/AzureResourceGroupDeploymentV2/task.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 157, - "Patch": 7 + "Patch": 8 }, "demands": [], "minimumAgentVersion": "2.119.1", diff --git a/Tasks/AzureResourceGroupDeploymentV2/task.loc.json b/Tasks/AzureResourceGroupDeploymentV2/task.loc.json index b220da0d16ac..927c298f992b 100644 --- a/Tasks/AzureResourceGroupDeploymentV2/task.loc.json +++ b/Tasks/AzureResourceGroupDeploymentV2/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 2, "Minor": 157, - "Patch": 7 + "Patch": 8 }, "demands": [], "minimumAgentVersion": "2.119.1", diff --git a/Tasks/AzureResourceManagerTemplateDeploymentV3/operations/Utils.ts b/Tasks/AzureResourceManagerTemplateDeploymentV3/operations/Utils.ts index ec2b1e18c97e..a4e9c38c8712 100644 --- a/Tasks/AzureResourceManagerTemplateDeploymentV3/operations/Utils.ts +++ b/Tasks/AzureResourceManagerTemplateDeploymentV3/operations/Utils.ts @@ -200,7 +200,7 @@ class Utils { public static createDeploymentName(taskParameters: armDeployTaskParameters.TaskParameters): string { var name: string; if (taskParameters.templateLocation == "Linked artifact") { - name = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), taskParameters.csmFile)[0]; + name = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(taskParameters.csmFile))[0]; } else { name = taskParameters.csmFileLink; } @@ -224,7 +224,7 @@ class Utils { public static getDeploymentDataForLinkedArtifact(taskParameters: armDeployTaskParameters.TaskParameters): DeploymentParameters { var template: TemplateObject; - var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), taskParameters.csmFile); + var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(taskParameters.csmFile)); if (fileMatches.length > 1) { throw new Error(tl.loc("TemplateFilePatternMatchingMoreThanOneFile", fileMatches)); } @@ -247,7 +247,7 @@ class Utils { var parameters: Map = {} as Map; if (this.isNonEmpty(taskParameters.csmParametersFile)) { - var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), taskParameters.csmParametersFile); + var fileMatches = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory"), this.escapeBlockCharacters(taskParameters.csmParametersFile)); if (fileMatches.length > 1) { throw new Error(tl.loc("TemplateParameterFilePatternMatchingMoreThanOneFile", fileMatches)); } @@ -403,6 +403,10 @@ class Utils { return result; } + + private static escapeBlockCharacters(str: string): string { + return str.replace(/[\[]/g, '$&[]'); + } } export = Utils; \ No newline at end of file diff --git a/Tasks/AzureResourceManagerTemplateDeploymentV3/task.json b/Tasks/AzureResourceManagerTemplateDeploymentV3/task.json index 967fe4c5d4b4..c8b58e7e6c12 100644 --- a/Tasks/AzureResourceManagerTemplateDeploymentV3/task.json +++ b/Tasks/AzureResourceManagerTemplateDeploymentV3/task.json @@ -15,7 +15,7 @@ "version": { "Major": 3, "Minor": 1, - "Patch": 4 + "Patch": 5 }, "preview": "true", "demands": [], diff --git a/Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json b/Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json index 9bb806e03ec4..e7b07e0c7928 100644 --- a/Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json +++ b/Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 3, "Minor": 1, - "Patch": 4 + "Patch": 5 }, "preview": "true", "demands": [],