Skip to content

Commit ba56ae3

Browse files
authored
AzCli task reset to m142 for RC2 (#9059)
* Revert "Setting up Azure Active cloud corresponding to service endpoint (#9003) (#9006)" This reverts commit 8ebe8db. * Revert "Add Global Azure CLI config flag (#8996) (#8998)" This reverts commit be92e08. * Revert "Azure cli path undefined fix. (#8954)" This reverts commit 2a04bae. * Revert "Set local confg dir for az cli so that multiple tasks can run in parallel (#8656)" This reverts commit f29fe65. * increase version
1 parent 6c3c07b commit ba56ae3

File tree

4 files changed

+7
-72
lines changed

4 files changed

+7
-72
lines changed

Tasks/AzureCLIV1/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"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",
1616
"loc.input.label.args": "Arguments",
1717
"loc.input.help.args": "Arguments passed to the script",
18-
"loc.input.label.useGlobalConfig": "Use global Azure CLI configuration",
19-
"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",
2018
"loc.input.label.cwd": "Working Directory",
2119
"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)",
2220
"loc.input.label.failOnStandardError": "Fail on Standard Error",
@@ -27,7 +25,5 @@
2725
"loc.messages.AzureSDKNotFound": "Azure CLI 2.x is not installed on this machine.",
2826
"loc.messages.FailedToLogout": "The following error occurred while logging out: %s",
2927
"loc.messages.LoginFailed": "Azure login failed",
30-
"loc.messages.ErrorInSettingUpSubscription": "Error in setting up subscription",
31-
"loc.messages.SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s",
32-
"loc.messages.SettingAzureCloud": "Setting active cloud to: %s"
28+
"loc.messages.ErrorInSettingUpSubscription": "Error in setting up subscription"
3329
}

Tasks/AzureCLIV1/azureclitask.ts

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export class azureclitask {
5757
tool = tl.tool(tl.which(scriptPath, true));
5858
}
5959
this.throwIfError(tl.execSync("az", "--version"));
60-
// set az cli config dir
61-
this.setConfigDirectory();
62-
this.setAzureCloudBasedOnServiceEndpoint();
6360
this.loginAzure();
6461

6562
tool.line(args); // additional args should always call line. line() parses quoted arg strings
@@ -79,7 +76,7 @@ export class azureclitask {
7976
this.deleteFile(scriptPath);
8077
}
8178

82-
if (this.cliPasswordPath) {
79+
if(this.cliPasswordPath) {
8380
tl.debug('Removing spn certificate file');
8481
tl.rmRF(this.cliPasswordPath);
8582
}
@@ -89,10 +86,6 @@ export class azureclitask {
8986
this.logoutAzure();
9087
}
9188

92-
if (this.azCliConfigPath) {
93-
tl.rmRF(this.azCliConfigPath);
94-
}
95-
9689
//set the task result to either succeeded or failed based on error was thrown or not
9790
if (toolExecutionError) {
9891
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailed", toolExecutionError));
@@ -105,7 +98,6 @@ export class azureclitask {
10598

10699
private static isLoggedIn: boolean = false;
107100
private static cliPasswordPath: string = null;
108-
private static azCliConfigPath: string;
109101

110102
private static loginAzure() {
111103
var connectedService: string = tl.getInput("connectedServiceNameARM", true);
@@ -116,7 +108,7 @@ export class azureclitask {
116108
var servicePrincipalId: string = tl.getEndpointAuthorizationParameter(connectedService, "serviceprincipalid", false);
117109
let authType: string = tl.getEndpointAuthorizationParameter(connectedService, 'authenticationType', true);
118110
let cliPassword: string = null;
119-
if (authType == "spnCertificate") {
111+
if(authType == "spnCertificate") {
120112
tl.debug('certificate based endpoint');
121113
let certificateContent: string = tl.getEndpointAuthorizationParameter(connectedService, "servicePrincipalCertificate", false);
122114
cliPassword = path.join(tl.getVariable('Agent.TempDirectory') || tl.getVariable('system.DefaultWorkingDirectory'), 'spnCert.pem');
@@ -131,44 +123,13 @@ export class azureclitask {
131123

132124
var tenantId: string = tl.getEndpointAuthorizationParameter(connectedService, "tenantid", false);
133125
var subscriptionID: string = tl.getEndpointDataParameter(connectedService, "SubscriptionID", true);
134-
135126
//login using svn
136127
this.throwIfError(tl.execSync("az", "login --service-principal -u \"" + servicePrincipalId + "\" -p \"" + cliPassword + "\" --tenant \"" + tenantId + "\""), tl.loc("LoginFailed"));
137128
this.isLoggedIn = true;
138129
//set the subscription imported to the current subscription
139130
this.throwIfError(tl.execSync("az", "account set --subscription \"" + subscriptionID + "\""), tl.loc("ErrorInSettingUpSubscription"));
140131
}
141132

142-
private static setConfigDirectory(): void {
143-
if (tl.getBoolInput("useGlobalConfig")) {
144-
return;
145-
}
146-
147-
var configDirName: string = "c" + new Date().getTime(); // 'c' denotes config
148-
var basePath: string;
149-
if (tl.osType().match(/^Win/)) {
150-
basePath = process.env.USERPROFILE;
151-
}
152-
else {
153-
basePath = process.env.HOME;
154-
}
155-
156-
if (!!basePath) {
157-
this.azCliConfigPath = path.join(basePath, ".azclitask", configDirName);
158-
console.log(tl.loc('SettingAzureConfigDir', this.azCliConfigPath));
159-
process.env['AZURE_CONFIG_DIR'] = this.azCliConfigPath;
160-
}
161-
}
162-
163-
private static setAzureCloudBasedOnServiceEndpoint(): void {
164-
var connectedService: string = tl.getInput("connectedServiceNameARM", true);
165-
var environment = tl.getEndpointDataParameter(connectedService, 'environment', true);
166-
if(!!environment) {
167-
console.log(tl.loc('SettingAzureCloud', environment));
168-
this.throwIfError(tl.execSync("az", "cloud set -n " + environment));
169-
}
170-
}
171-
172133
private static logoutAzure() {
173134
try {
174135
tl.execSync("az", " account clear");

Tasks/AzureCLIV1/task.json

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"version": {
2020
"Major": 1,
2121
"Minor": 143,
22-
"Patch": 5
22+
"Patch": 6
2323
},
2424
"minimumAgentVersion": "2.0.0",
2525
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -90,15 +90,6 @@
9090
"editorExtension": "ms.vss-services-azure.parameters-grid"
9191
}
9292
},
93-
{
94-
"name": "useGlobalConfig",
95-
"type": "boolean",
96-
"label": "Use global Azure CLI configuration",
97-
"defaultValue": "false",
98-
"required": false,
99-
"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",
100-
"groupName": "advanced"
101-
},
10293
{
10394
"name": "cwd",
10495
"aliases": [
@@ -134,8 +125,6 @@
134125
"AzureSDKNotFound": "Azure CLI 2.x is not installed on this machine.",
135126
"FailedToLogout": "The following error occurred while logging out: %s",
136127
"LoginFailed": "Azure login failed",
137-
"ErrorInSettingUpSubscription": "Error in setting up subscription",
138-
"SettingAzureConfigDir": "Setting AZURE_CONFIG_DIR env variable to: %s",
139-
"SettingAzureCloud": "Setting active cloud to: %s"
128+
"ErrorInSettingUpSubscription": "Error in setting up subscription"
140129
}
141130
}

Tasks/AzureCLIV1/task.loc.json

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"version": {
2020
"Major": 1,
2121
"Minor": 143,
22-
"Patch": 5
22+
"Patch": 6
2323
},
2424
"minimumAgentVersion": "2.0.0",
2525
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -90,15 +90,6 @@
9090
"editorExtension": "ms.vss-services-azure.parameters-grid"
9191
}
9292
},
93-
{
94-
"name": "useGlobalConfig",
95-
"type": "boolean",
96-
"label": "ms-resource:loc.input.label.useGlobalConfig",
97-
"defaultValue": "false",
98-
"required": false,
99-
"helpMarkDown": "ms-resource:loc.input.help.useGlobalConfig",
100-
"groupName": "advanced"
101-
},
10293
{
10394
"name": "cwd",
10495
"aliases": [
@@ -134,8 +125,6 @@
134125
"AzureSDKNotFound": "ms-resource:loc.messages.AzureSDKNotFound",
135126
"FailedToLogout": "ms-resource:loc.messages.FailedToLogout",
136127
"LoginFailed": "ms-resource:loc.messages.LoginFailed",
137-
"ErrorInSettingUpSubscription": "ms-resource:loc.messages.ErrorInSettingUpSubscription",
138-
"SettingAzureConfigDir": "ms-resource:loc.messages.SettingAzureConfigDir",
139-
"SettingAzureCloud": "ms-resource:loc.messages.SettingAzureCloud"
128+
"ErrorInSettingUpSubscription": "ms-resource:loc.messages.ErrorInSettingUpSubscription"
140129
}
141130
}

0 commit comments

Comments
 (0)