azure-pipelines-tasks-azurermdeploycommon 3.222.1 → 3.226.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,16 +5,6 @@ export declare class ContainerBasedDeploymentUtility {
|
|
|
5
5
|
constructor(appService: AzureAppService);
|
|
6
6
|
deployWebAppImage(properties: any, restart?: boolean): Promise<void>;
|
|
7
7
|
private _updateConfigurationDetails;
|
|
8
|
-
private _getAzureContainerImageName;
|
|
9
|
-
private _getDockerHubImageName;
|
|
10
|
-
private _constructImageName;
|
|
11
|
-
private _getPrivateRegistryImageName;
|
|
12
|
-
private _updateWebAppSettings;
|
|
13
|
-
private _getImageName;
|
|
14
|
-
private _getContainerRegistrySettings;
|
|
15
|
-
private _getAzureContainerRegistrySettings;
|
|
16
|
-
private _getDockerPrivateRegistrySettings;
|
|
17
|
-
private _deleteRegistryConnectionSettings;
|
|
18
8
|
private updateImagesInConfigFile;
|
|
19
9
|
private tokenizeImages;
|
|
20
10
|
}
|
|
@@ -11,19 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ContainerBasedDeploymentUtility = void 0;
|
|
13
13
|
const tl = require("azure-pipelines-task-lib/task");
|
|
14
|
-
const url = require("url");
|
|
15
|
-
const util = require("util");
|
|
16
14
|
const ParameterParserUtility_1 = require("./ParameterParserUtility");
|
|
17
15
|
const AzureAppServiceUtility_1 = require("./AzureAppServiceUtility");
|
|
18
16
|
const fs = require("fs");
|
|
19
17
|
const path = require("path");
|
|
20
18
|
var deployUtility = require('../webdeployment-common/utility.js');
|
|
21
|
-
var registryTypes;
|
|
22
|
-
(function (registryTypes) {
|
|
23
|
-
registryTypes[registryTypes["AzureContainerRegistry"] = 0] = "AzureContainerRegistry";
|
|
24
|
-
registryTypes[registryTypes["Registry"] = 1] = "Registry";
|
|
25
|
-
registryTypes[registryTypes["PrivateRegistry"] = 2] = "PrivateRegistry";
|
|
26
|
-
})(registryTypes || (registryTypes = {}));
|
|
27
19
|
class ContainerBasedDeploymentUtility {
|
|
28
20
|
constructor(appService) {
|
|
29
21
|
this._appService = appService;
|
|
@@ -83,128 +75,6 @@ class ContainerBasedDeploymentUtility {
|
|
|
83
75
|
yield this._appServiceUtility.updateConfigurationSettings(appSettingsNewProperties);
|
|
84
76
|
});
|
|
85
77
|
}
|
|
86
|
-
_getAzureContainerImageName() {
|
|
87
|
-
var registry = tl.getInput('AzureContainerRegistryLoginServer', true) + ".azurecr.io";
|
|
88
|
-
var image = tl.getInput('AzureContainerRegistryImage', true);
|
|
89
|
-
var tag = tl.getInput('AzureContainerRegistryTag', false);
|
|
90
|
-
return this._constructImageName(registry, image, tag);
|
|
91
|
-
}
|
|
92
|
-
_getDockerHubImageName() {
|
|
93
|
-
var namespace = tl.getInput('DockerNamespace', true);
|
|
94
|
-
var image = tl.getInput('DockerRepository', true);
|
|
95
|
-
var tag = tl.getInput('DockerImageTag', false);
|
|
96
|
-
return this._constructImageName(namespace, image, tag);
|
|
97
|
-
}
|
|
98
|
-
_constructImageName(namespace, repository, tag) {
|
|
99
|
-
var imageName = null;
|
|
100
|
-
/*
|
|
101
|
-
Special Case : If release definition is not linked to build artifacts
|
|
102
|
-
then $(Build.BuildId) variable don't expand in release. So clearing state
|
|
103
|
-
of dockerImageTag if $(Build.BuildId) not expanded in value of dockerImageTag.
|
|
104
|
-
*/
|
|
105
|
-
if (tag && (tag.trim() == "$(Build.BuildId)")) {
|
|
106
|
-
tag = null;
|
|
107
|
-
}
|
|
108
|
-
if (tag) {
|
|
109
|
-
imageName = namespace.toLowerCase() + "/" + repository.toLowerCase() + ":" + tag;
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
imageName = namespace.toLowerCase() + "/" + repository.toLowerCase();
|
|
113
|
-
}
|
|
114
|
-
return imageName.replace(/ /g, "");
|
|
115
|
-
}
|
|
116
|
-
_getPrivateRegistryImageName() {
|
|
117
|
-
var registryConnectedServiceName = tl.getInput('RegistryConnectedServiceName', true);
|
|
118
|
-
var loginServer = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'url', true);
|
|
119
|
-
var registry = url.parse(loginServer).hostname;
|
|
120
|
-
var image = tl.getInput('PrivateRegistryImage', true);
|
|
121
|
-
var tag = tl.getInput('PrivateRegistryTag', false);
|
|
122
|
-
return this._constructImageName(registry, image, tag);
|
|
123
|
-
}
|
|
124
|
-
_updateWebAppSettings(appSettingsParameters, webAppSettings) {
|
|
125
|
-
// In case of public repo, clear the connection details of a registry
|
|
126
|
-
var dockerRespositoryAccess = tl.getInput('DockerRepositoryAccess', true);
|
|
127
|
-
// Uncomment the below lines while supprting all registry types.
|
|
128
|
-
// if(dockerRespositoryAccess === "public")
|
|
129
|
-
// {
|
|
130
|
-
// deleteRegistryConnectionSettings(webAppSettings);
|
|
131
|
-
// }
|
|
132
|
-
var parsedAppSettings = ParameterParserUtility_1.parse(appSettingsParameters);
|
|
133
|
-
for (var settingName in parsedAppSettings) {
|
|
134
|
-
var setting = settingName.trim();
|
|
135
|
-
var settingVal = parsedAppSettings[settingName].value;
|
|
136
|
-
settingVal = settingVal ? settingVal.trim() : "";
|
|
137
|
-
if (setting) {
|
|
138
|
-
webAppSettings["properties"][setting] = settingVal;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
_getImageName() {
|
|
143
|
-
var registryType = tl.getInput('ImageSource', true);
|
|
144
|
-
var imageName = null;
|
|
145
|
-
switch (registryType) {
|
|
146
|
-
case registryTypes[registryTypes.AzureContainerRegistry]:
|
|
147
|
-
imageName = this._getAzureContainerImageName();
|
|
148
|
-
break;
|
|
149
|
-
case registryTypes[registryTypes.Registry]:
|
|
150
|
-
imageName = this._getDockerHubImageName();
|
|
151
|
-
break;
|
|
152
|
-
case registryTypes[registryTypes.PrivateRegistry]:
|
|
153
|
-
imageName = this._getPrivateRegistryImageName();
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
return imageName;
|
|
157
|
-
}
|
|
158
|
-
_getContainerRegistrySettings(imageName, endPoint) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var containerRegistryType = 'Registry';
|
|
161
|
-
var containerRegistrySettings = "-DOCKER_CUSTOM_IMAGE_NAME " + imageName;
|
|
162
|
-
var containerRegistryAuthParamsFormatString = "-DOCKER_REGISTRY_SERVER_URL %s -DOCKER_REGISTRY_SERVER_USERNAME %s -DOCKER_REGISTRY_SERVER_PASSWORD %s";
|
|
163
|
-
switch (containerRegistryType) {
|
|
164
|
-
case registryTypes[registryTypes.AzureContainerRegistry]:
|
|
165
|
-
containerRegistrySettings = yield this._getAzureContainerRegistrySettings(endPoint, containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
166
|
-
break;
|
|
167
|
-
case registryTypes[registryTypes.Registry]:
|
|
168
|
-
var dockerRespositoryAccess = tl.getInput('DockerRepositoryAccess', false);
|
|
169
|
-
if (dockerRespositoryAccess === "private") {
|
|
170
|
-
containerRegistrySettings = this._getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case registryTypes[registryTypes.PrivateRegistry]:
|
|
174
|
-
containerRegistrySettings = this._getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
return containerRegistrySettings;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
_getAzureContainerRegistrySettings(endPoint, containerRegistrySettings, containerRegistryAuthParamsFormatString) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
var registryServerName = tl.getInput('AzureContainerRegistryLoginServer', true);
|
|
183
|
-
var registryUrl = "https://" + registryServerName + ".azurecr.io";
|
|
184
|
-
tl.debug("Azure Container Registry Url: " + registryUrl);
|
|
185
|
-
var registryName = tl.getInput('AzureContainerRegistry', true);
|
|
186
|
-
var resourceGroupName = ''; // await azureRESTUtility.getResourceGroupName(endPoint, registryName, "Microsoft.ContainerRegistry/registries");
|
|
187
|
-
tl.debug("Resource group name of a registry: " + resourceGroupName);
|
|
188
|
-
var creds = null; //await azureRESTUtility.getAzureContainerRegistryCredentials(endPoint, registryName, resourceGroupName);
|
|
189
|
-
tl.debug("Successfully retrieved the registry credentials");
|
|
190
|
-
var username = creds.username;
|
|
191
|
-
var password = creds["passwords"][0].value;
|
|
192
|
-
return containerRegistrySettings + " " + util.format(containerRegistryAuthParamsFormatString, registryUrl, username, password);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
_getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString) {
|
|
196
|
-
var registryConnectedServiceName = tl.getInput('RegistryConnectedServiceName', true);
|
|
197
|
-
var username = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'username', true);
|
|
198
|
-
var password = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'password', true);
|
|
199
|
-
var registryUrl = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'registry', true);
|
|
200
|
-
tl.debug("Docker or Private Container Registry Url: " + registryUrl);
|
|
201
|
-
return containerRegistrySettings + " " + util.format(containerRegistryAuthParamsFormatString, registryUrl, username, password);
|
|
202
|
-
}
|
|
203
|
-
_deleteRegistryConnectionSettings(webAppSettings) {
|
|
204
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_URL"];
|
|
205
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_USERNAME"];
|
|
206
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_PASSWORD"];
|
|
207
|
-
}
|
|
208
78
|
updateImagesInConfigFile(multicontainerConfigFile, images) {
|
|
209
79
|
const tempDirectory = deployUtility.getTempDirectory();
|
|
210
80
|
var contents = fs.readFileSync(multicontainerConfigFile).toString();
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import tl = require('azure-pipelines-task-lib/task');
|
|
2
|
-
import url = require('url');
|
|
3
|
-
import util = require('util');
|
|
4
2
|
import { AzureAppService } from '../azure-arm-rest/azure-arm-app-service';
|
|
5
3
|
import { parse } from './ParameterParserUtility';
|
|
6
4
|
import { AzureAppServiceUtility } from './AzureAppServiceUtility';
|
|
@@ -8,12 +6,6 @@ import fs = require('fs');
|
|
|
8
6
|
import path = require('path');
|
|
9
7
|
var deployUtility = require('../webdeployment-common/utility.js');
|
|
10
8
|
|
|
11
|
-
enum registryTypes {
|
|
12
|
-
"AzureContainerRegistry",
|
|
13
|
-
"Registry", // TODO: Rename it to DockerHub while supporting all the registry types. Also add all these registry types in Task.json in ImageSource pick list.
|
|
14
|
-
"PrivateRegistry"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
export class ContainerBasedDeploymentUtility {
|
|
18
10
|
private _appService: AzureAppService;
|
|
19
11
|
private _appServiceUtility: AzureAppServiceUtility;
|
|
@@ -81,156 +73,6 @@ export class ContainerBasedDeploymentUtility {
|
|
|
81
73
|
await this._appServiceUtility.updateConfigurationSettings(appSettingsNewProperties);
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
private _getAzureContainerImageName(): string {
|
|
85
|
-
var registry = tl.getInput('AzureContainerRegistryLoginServer', true) + ".azurecr.io";
|
|
86
|
-
var image = tl.getInput('AzureContainerRegistryImage', true);
|
|
87
|
-
var tag = tl.getInput('AzureContainerRegistryTag', false);
|
|
88
|
-
|
|
89
|
-
return this._constructImageName(registry, image, tag);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private _getDockerHubImageName(): string {
|
|
93
|
-
var namespace = tl.getInput('DockerNamespace', true);
|
|
94
|
-
var image = tl.getInput('DockerRepository', true);
|
|
95
|
-
var tag = tl.getInput('DockerImageTag', false);
|
|
96
|
-
|
|
97
|
-
return this._constructImageName(namespace, image, tag);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private _constructImageName(namespace, repository, tag): string {
|
|
101
|
-
var imageName = null;
|
|
102
|
-
/*
|
|
103
|
-
Special Case : If release definition is not linked to build artifacts
|
|
104
|
-
then $(Build.BuildId) variable don't expand in release. So clearing state
|
|
105
|
-
of dockerImageTag if $(Build.BuildId) not expanded in value of dockerImageTag.
|
|
106
|
-
*/
|
|
107
|
-
if(tag && (tag.trim() == "$(Build.BuildId)")) {
|
|
108
|
-
tag = null;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if(tag) {
|
|
112
|
-
imageName = namespace.toLowerCase() + "/" + repository.toLowerCase() + ":" + tag;
|
|
113
|
-
} else {
|
|
114
|
-
imageName = namespace.toLowerCase() + "/" + repository.toLowerCase();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return imageName.replace(/ /g,"");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private _getPrivateRegistryImageName(): string {
|
|
121
|
-
var registryConnectedServiceName = tl.getInput('RegistryConnectedServiceName', true);
|
|
122
|
-
var loginServer = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'url', true);
|
|
123
|
-
|
|
124
|
-
var registry = url.parse(loginServer).hostname;
|
|
125
|
-
var image = tl.getInput('PrivateRegistryImage', true);
|
|
126
|
-
var tag = tl.getInput('PrivateRegistryTag', false);
|
|
127
|
-
|
|
128
|
-
return this._constructImageName(registry, image, tag);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private _updateWebAppSettings(appSettingsParameters, webAppSettings): void {
|
|
132
|
-
// In case of public repo, clear the connection details of a registry
|
|
133
|
-
var dockerRespositoryAccess = tl.getInput('DockerRepositoryAccess', true);
|
|
134
|
-
|
|
135
|
-
// Uncomment the below lines while supprting all registry types.
|
|
136
|
-
// if(dockerRespositoryAccess === "public")
|
|
137
|
-
// {
|
|
138
|
-
// deleteRegistryConnectionSettings(webAppSettings);
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
var parsedAppSettings = parse(appSettingsParameters);
|
|
142
|
-
for (var settingName in parsedAppSettings) {
|
|
143
|
-
var setting = settingName.trim();
|
|
144
|
-
var settingVal = parsedAppSettings[settingName].value;
|
|
145
|
-
settingVal = settingVal ? settingVal.trim() : "";
|
|
146
|
-
|
|
147
|
-
if(setting) {
|
|
148
|
-
webAppSettings["properties"][setting] = settingVal;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private _getImageName(): string {
|
|
154
|
-
var registryType = tl.getInput('ImageSource', true);
|
|
155
|
-
var imageName = null;
|
|
156
|
-
|
|
157
|
-
switch(registryType) {
|
|
158
|
-
case registryTypes[registryTypes.AzureContainerRegistry]:
|
|
159
|
-
imageName = this._getAzureContainerImageName();
|
|
160
|
-
break;
|
|
161
|
-
|
|
162
|
-
case registryTypes[registryTypes.Registry]:
|
|
163
|
-
imageName = this._getDockerHubImageName();
|
|
164
|
-
break;
|
|
165
|
-
|
|
166
|
-
case registryTypes[registryTypes.PrivateRegistry]:
|
|
167
|
-
imageName = this._getPrivateRegistryImageName();
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return imageName;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private async _getContainerRegistrySettings(imageName, endPoint): Promise<string> {
|
|
175
|
-
var containerRegistryType: string = 'Registry';
|
|
176
|
-
var containerRegistrySettings: string = "-DOCKER_CUSTOM_IMAGE_NAME " + imageName;
|
|
177
|
-
var containerRegistryAuthParamsFormatString: string = "-DOCKER_REGISTRY_SERVER_URL %s -DOCKER_REGISTRY_SERVER_USERNAME %s -DOCKER_REGISTRY_SERVER_PASSWORD %s";
|
|
178
|
-
|
|
179
|
-
switch(containerRegistryType) {
|
|
180
|
-
case registryTypes[registryTypes.AzureContainerRegistry]:
|
|
181
|
-
containerRegistrySettings = await this._getAzureContainerRegistrySettings(endPoint, containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
182
|
-
break;
|
|
183
|
-
|
|
184
|
-
case registryTypes[registryTypes.Registry]:
|
|
185
|
-
var dockerRespositoryAccess = tl.getInput('DockerRepositoryAccess', false);
|
|
186
|
-
if(dockerRespositoryAccess === "private")
|
|
187
|
-
{
|
|
188
|
-
containerRegistrySettings = this._getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
189
|
-
}
|
|
190
|
-
break;
|
|
191
|
-
|
|
192
|
-
case registryTypes[registryTypes.PrivateRegistry]:
|
|
193
|
-
containerRegistrySettings = this._getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return containerRegistrySettings;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private async _getAzureContainerRegistrySettings(endPoint, containerRegistrySettings, containerRegistryAuthParamsFormatString): Promise<string> {
|
|
201
|
-
var registryServerName = tl.getInput('AzureContainerRegistryLoginServer', true);
|
|
202
|
-
var registryUrl = "https://" + registryServerName + ".azurecr.io";
|
|
203
|
-
tl.debug("Azure Container Registry Url: " + registryUrl);
|
|
204
|
-
|
|
205
|
-
var registryName = tl.getInput('AzureContainerRegistry', true);
|
|
206
|
-
var resourceGroupName = '';// await azureRESTUtility.getResourceGroupName(endPoint, registryName, "Microsoft.ContainerRegistry/registries");
|
|
207
|
-
tl.debug("Resource group name of a registry: " + resourceGroupName);
|
|
208
|
-
|
|
209
|
-
var creds = null //await azureRESTUtility.getAzureContainerRegistryCredentials(endPoint, registryName, resourceGroupName);
|
|
210
|
-
tl.debug("Successfully retrieved the registry credentials");
|
|
211
|
-
|
|
212
|
-
var username = creds.username;
|
|
213
|
-
var password = creds["passwords"][0].value;
|
|
214
|
-
|
|
215
|
-
return containerRegistrySettings + " " + util.format(containerRegistryAuthParamsFormatString, registryUrl, username, password);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
private _getDockerPrivateRegistrySettings(containerRegistrySettings, containerRegistryAuthParamsFormatString): string {
|
|
219
|
-
var registryConnectedServiceName = tl.getInput('RegistryConnectedServiceName', true);
|
|
220
|
-
var username = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'username', true);
|
|
221
|
-
var password = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'password', true);
|
|
222
|
-
var registryUrl = tl.getEndpointAuthorizationParameter(registryConnectedServiceName, 'registry', true);
|
|
223
|
-
|
|
224
|
-
tl.debug("Docker or Private Container Registry Url: " + registryUrl);
|
|
225
|
-
|
|
226
|
-
return containerRegistrySettings + " " + util.format(containerRegistryAuthParamsFormatString, registryUrl, username, password);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
private _deleteRegistryConnectionSettings(webAppSettings): void {
|
|
230
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_URL"];
|
|
231
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_USERNAME"];
|
|
232
|
-
delete webAppSettings["properties"]["DOCKER_REGISTRY_SERVER_PASSWORD"];
|
|
233
|
-
}
|
|
234
76
|
|
|
235
77
|
private updateImagesInConfigFile(multicontainerConfigFile, images): string {
|
|
236
78
|
const tempDirectory = deployUtility.getTempDirectory();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-pipelines-tasks-azurermdeploycommon",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.226.0",
|
|
4
4
|
"description": "Common Lib for Azure ARM REST apis",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"q": "1.5.1",
|
|
29
29
|
"typed-rest-client": "^1.8.4",
|
|
30
30
|
"winreg": "1.2.2",
|
|
31
|
-
"xml2js": "0.
|
|
31
|
+
"xml2js": "0.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"typescript": "4.0.2"
|