Skip to content

Commit

Permalink
Add Global Azure CLI config flag (#8996)
Browse files Browse the repository at this point in the history
* Add Global Azure CLI config flag

* Fix review comment

* revert earlier commit
  • Loading branch information
vineetmimrot authored Dec 4, 2018
1 parent 59a8046 commit 79ba54b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion Tasks/AzureCLIV1/azureclitask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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/)) {
Expand Down
11 changes: 10 additions & 1 deletion Tasks/AzureCLIV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 144,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "Azure CLI $(scriptPath)",
Expand Down Expand Up @@ -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": [
Expand Down
11 changes: 10 additions & 1 deletion Tasks/AzureCLIV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 1,
"Minor": 144,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 79ba54b

Please sign in to comment.