diff --git a/Tasks/AzureCLIV1/Strings/resources.resjson/en-US/resources.resjson b/Tasks/AzureCLIV1/Strings/resources.resjson/en-US/resources.resjson index d18201caa443..9c1d4703b5c2 100644 --- a/Tasks/AzureCLIV1/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/AzureCLIV1/Strings/resources.resjson/en-US/resources.resjson @@ -16,9 +16,11 @@ "loc.input.label.args": "Arguments", "loc.input.help.args": "Arguments passed to the script", "loc.input.label.addSpnToEnvironment": "Access service principal details in script", - "loc.input.help.addSpnToEnvironment": "Adds service principal id and key of the Azure subscription endpoint you chose, to the script's execution environment. You can use these variables: `$servicePrincipalId` and `$servicePrincipalKey` in your script", + "loc.input.help.addSpnToEnvironment": "Adds service principal id and key of the Azure endpoint you chose to the script's execution environment. You can use these variables: `$servicePrincipalId` and `$servicePrincipalKey` in your script", "loc.input.label.cwd": "Working Directory", "loc.input.help.cwd": "Current working directory where the script is run. Empty is the root of the repo (build) or artifacts (release), which is $(System.DefaultWorkingDirectory)", + "loc.input.label.useGlobalConfig": "Use global Azure CLI configuration", + "loc.input.help.useGlobalConfig": "If this is false, this task will use its own separate [*AzCLI configuration directory*](https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration?view=azure-cli-latest#cli-configuration-file). This can be used to run Azure CLI tasks in *parallel* releases", "loc.input.label.failOnStandardError": "Fail on Standard Error", "loc.input.help.failOnStandardError": "If this is true, this task will fail when any errors are written to the StandardError stream. Unselect the checkbox to ignore standard errors and rely on exit codes to determine the status", "loc.messages.ScriptReturnCode": "Script exited with return code: %d", diff --git a/Tasks/AzureCLIV1/azureclitask.ts b/Tasks/AzureCLIV1/azureclitask.ts index b3f780eff821..3af183bb7acb 100644 --- a/Tasks/AzureCLIV1/azureclitask.ts +++ b/Tasks/AzureCLIV1/azureclitask.ts @@ -57,6 +57,7 @@ export class azureclitask { tool = tl.tool(tl.which(scriptPath, true)); } this.throwIfError(tl.execSync("az", "--version")); + this.useGlobalConfig = tl.getBoolInput("useGlobalConfig"); this.loginAzure(); tool.line(args); // additional args should always call line. line() parses quoted arg strings @@ -114,7 +115,7 @@ export class azureclitask { private static isLoggedIn: boolean = false; private static cliPasswordPath: string = null; private static azCliConfigPath: string; - + private static useGlobalConfig: boolean = true; private static servicePrincipalId: string = null; private static servicePrincipalKey: string = null; @@ -157,6 +158,10 @@ export class azureclitask { } private static setConfigDirectory(): void { + if (this.useGlobalConfig) { + return; + } + var configDirName: string = "c" + new Date().getTime(); // 'c' denotes config var basePath: string; if (tl.osType().match(/^Win/)) { diff --git a/Tasks/AzureCLIV1/task.json b/Tasks/AzureCLIV1/task.json index 627d56f3f190..73d8bf9fce70 100644 --- a/Tasks/AzureCLIV1/task.json +++ b/Tasks/AzureCLIV1/task.json @@ -19,7 +19,7 @@ "version": { "Major": 1, "Minor": 144, - "Patch": 1 + "Patch": 2 }, "minimumAgentVersion": "2.0.0", "instanceNameFormat": "Azure CLI $(scriptPath)", @@ -99,6 +99,15 @@ "helpMarkDown": "Adds service principal id and key of the Azure endpoint you chose to the script's execution environment. You can use these variables: `$servicePrincipalId` and `$servicePrincipalKey` in your script", "groupName": "advanced" }, + { + "name": "useGlobalConfig", + "type": "boolean", + "label": "Use global Azure CLI configuration", + "defaultValue": "true", + "required": false, + "helpMarkDown": "If this is false, this task will use its own separate [Azure CLI configuration directory](https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration?view=azure-cli-latest#cli-configuration-file). This can be used to run Azure CLI tasks in *parallel* releases", + "groupName": "advanced" + }, { "name": "cwd", "aliases": [ diff --git a/Tasks/AzureCLIV1/task.loc.json b/Tasks/AzureCLIV1/task.loc.json index 32f4fb1209ad..4f457163a84c 100644 --- a/Tasks/AzureCLIV1/task.loc.json +++ b/Tasks/AzureCLIV1/task.loc.json @@ -19,7 +19,7 @@ "version": { "Major": 1, "Minor": 144, - "Patch": 1 + "Patch": 2 }, "minimumAgentVersion": "2.0.0", "instanceNameFormat": "ms-resource:loc.instanceNameFormat", @@ -111,6 +111,15 @@ "helpMarkDown": "ms-resource:loc.input.help.cwd", "groupName": "advanced" }, + { + "name": "useGlobalConfig", + "type": "boolean", + "label": "ms-resource:loc.input.label.useGlobalConfig", + "defaultValue": "true", + "required": false, + "helpMarkDown": "ms-resource:loc.input.help.useGlobalConfig", + "groupName": "advanced" + }, { "name": "failOnStandardError", "type": "boolean",