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 committed Dec 4, 2018
1 parent 382c82c commit 4c7712f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"loc.input.help.inlineScript": "You can write your scripts inline here. For batch files use the prefix \"call\" before every azure command. You can also pass predefined and custom variables to this script using arguments \n\n example for shell: az --version || az account show \n\n example for batch: call az --version || call az account show",
"loc.input.label.args": "Arguments",
"loc.input.help.args": "Arguments passed to the script",
"loc.input.label.useGlobalConfig": "Use global Azure CLI configuration",
"loc.input.help.useGlobalConfig": "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",
"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.failOnStandardError": "Fail on Standard Error",
Expand Down
6 changes: 6 additions & 0 deletions 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 @@ -103,6 +104,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 loginAzure() {
var connectedService: string = tl.getInput("connectedServiceNameARM", true);
Expand Down Expand Up @@ -140,6 +142,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": 143,
"Patch": 3
"Patch": 4
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "Azure CLI $(scriptPath)",
Expand Down Expand Up @@ -90,6 +90,15 @@
"editorExtension": "ms.vss-services-azure.parameters-grid"
}
},
{
"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": 143,
"Patch": 3
"Patch": 4
},
"minimumAgentVersion": "2.0.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -90,6 +90,15 @@
"editorExtension": "ms.vss-services-azure.parameters-grid"
}
},
{
"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": "cwd",
"aliases": [
Expand Down

0 comments on commit 4c7712f

Please sign in to comment.