Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Global Azure CLI config flag #8996

Merged
merged 3 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
vineetmimrot marked this conversation as resolved.
Show resolved Hide resolved
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