azure-pipelines-tasks-azurermdeploycommon 3.235.0 → 3.237.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.
- package/azure-arm-rest/azure-arm-app-service-kudu.d.ts +1 -0
- package/azure-arm-rest/azure-arm-app-service-kudu.js +37 -0
- package/azure-arm-rest/azure-arm-app-service-kudu.ts +36 -1
- package/operations/KuduServiceUtility.d.ts +1 -0
- package/operations/KuduServiceUtility.js +35 -0
- package/operations/KuduServiceUtility.ts +41 -1
- package/package.json +1 -2
- package/webdeployment-common/ziputility.d.ts +1 -1
- package/webdeployment-common/ziputility.js +17 -23
- package/webdeployment-common/ziputility.ts +19 -25
|
@@ -31,6 +31,7 @@ export declare class Kudu {
|
|
|
31
31
|
getKuduStackTrace(): string;
|
|
32
32
|
zipDeploy(webPackage: string, queryParameters?: Array<string>): Promise<any>;
|
|
33
33
|
warDeploy(webPackage: string, queryParameters?: Array<string>): Promise<any>;
|
|
34
|
+
oneDeploy(webPackage: string, queryParameters?: Array<string>): Promise<any>;
|
|
34
35
|
getDeploymentDetails(deploymentID: string): Promise<any>;
|
|
35
36
|
getDeploymentLogs(log_url: string): Promise<any>;
|
|
36
37
|
deleteFile(physicalPath: string, fileName: string): Promise<void>;
|
|
@@ -507,6 +507,43 @@ class Kudu {
|
|
|
507
507
|
}
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
|
+
oneDeploy(webPackage, queryParameters) {
|
|
511
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
512
|
+
let httpRequest = new webClient.WebRequest();
|
|
513
|
+
httpRequest.method = 'POST';
|
|
514
|
+
httpRequest.uri = this._client.getRequestUri(`/api/publish`, queryParameters);
|
|
515
|
+
httpRequest.body = fs.createReadStream(webPackage);
|
|
516
|
+
let requestOptions = new webClient.WebRequestOptions();
|
|
517
|
+
//Bydefault webclient.sendRequest retries for [500, 502, 503, 504]
|
|
518
|
+
requestOptions.retriableStatusCodes = [500, 502, 503, 504];
|
|
519
|
+
requestOptions.retryIntervalInSeconds = 5;
|
|
520
|
+
try {
|
|
521
|
+
let response = yield this._client.beginRequest(httpRequest, requestOptions, 'application/octet-stream');
|
|
522
|
+
tl.debug(`OneDeploy response: ${JSON.stringify(response)}`);
|
|
523
|
+
if (response.statusCode == 200) {
|
|
524
|
+
tl.debug('Deployment passed');
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
else if (response.statusCode == 202) {
|
|
528
|
+
let pollableURL = response.headers.location;
|
|
529
|
+
if (!!pollableURL) {
|
|
530
|
+
tl.debug(`Polling for OneDeploy URL: ${pollableURL}`);
|
|
531
|
+
return yield this._getDeploymentDetailsFromPollURL(pollableURL);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
tl.debug('OneDeploy returned 202 without pollable URL.');
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
throw response;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
throw new Error(tl.loc('PackageDeploymentFailed', this._getFormattedError(error)));
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
510
547
|
getDeploymentDetails(deploymentID) {
|
|
511
548
|
return __awaiter(this, void 0, void 0, function* () {
|
|
512
549
|
try {
|
|
@@ -522,6 +522,41 @@ export class Kudu {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
public async oneDeploy(webPackage: string, queryParameters?: Array<string>): Promise<any> {
|
|
526
|
+
let httpRequest = new webClient.WebRequest();
|
|
527
|
+
httpRequest.method = 'POST';
|
|
528
|
+
httpRequest.uri = this._client.getRequestUri(`/api/publish`, queryParameters);
|
|
529
|
+
httpRequest.body = fs.createReadStream(webPackage);
|
|
530
|
+
let requestOptions = new webClient.WebRequestOptions();
|
|
531
|
+
//Bydefault webclient.sendRequest retries for [500, 502, 503, 504]
|
|
532
|
+
requestOptions.retriableStatusCodes = [500, 502, 503, 504];
|
|
533
|
+
requestOptions.retryIntervalInSeconds = 5;
|
|
534
|
+
try {
|
|
535
|
+
let response = await this._client.beginRequest(httpRequest, requestOptions, 'application/octet-stream');
|
|
536
|
+
tl.debug(`OneDeploy response: ${JSON.stringify(response)}`);
|
|
537
|
+
if (response.statusCode == 200) {
|
|
538
|
+
tl.debug('Deployment passed');
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
else if (response.statusCode == 202) {
|
|
542
|
+
let pollableURL: string = response.headers.location;
|
|
543
|
+
if (!!pollableURL) {
|
|
544
|
+
tl.debug(`Polling for OneDeploy URL: ${pollableURL}`);
|
|
545
|
+
return await this._getDeploymentDetailsFromPollURL(pollableURL);
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
tl.debug('OneDeploy returned 202 without pollable URL.');
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
throw response;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
throw new Error(tl.loc('PackageDeploymentFailed', this._getFormattedError(error)));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
525
560
|
|
|
526
561
|
public async getDeploymentDetails(deploymentID: string): Promise<any> {
|
|
527
562
|
try {
|
|
@@ -648,4 +683,4 @@ export class Kudu {
|
|
|
648
683
|
}
|
|
649
684
|
return error;
|
|
650
685
|
}
|
|
651
|
-
}
|
|
686
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare class KuduServiceUtility {
|
|
|
12
12
|
deployUsingWarDeploy(packagePath: string, customMessage?: any, targetFolderName?: any): Promise<string>;
|
|
13
13
|
postZipDeployOperation(oldDeploymentID: string, activeDeploymentID: string): Promise<void>;
|
|
14
14
|
warmpUp(): Promise<void>;
|
|
15
|
+
deployUsingOneDeploy(packagePath: string, customMessage?: any, targetPath?: any, type?: any, clean?: any, restart?: any): Promise<string>;
|
|
15
16
|
private _processDeploymentResponse;
|
|
16
17
|
private _printZipDeployLogs;
|
|
17
18
|
private _printPostDeploymentLogs;
|
|
@@ -21,6 +21,7 @@ const physicalRootPath = '/site/wwwroot';
|
|
|
21
21
|
const deploymentFolder = 'site/deployments';
|
|
22
22
|
const manifestFileName = 'manifest';
|
|
23
23
|
const VSTS_ZIP_DEPLOY = 'VSTS_ZIP_DEPLOY';
|
|
24
|
+
const VSTS_ONE_DEPLOY = 'VSTS_ONE_DEPLOY';
|
|
24
25
|
const VSTS_DEPLOY = 'VSTS';
|
|
25
26
|
class KuduServiceUtility {
|
|
26
27
|
constructor(kuduService) {
|
|
@@ -190,6 +191,40 @@ class KuduServiceUtility {
|
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
}
|
|
194
|
+
deployUsingOneDeploy(packagePath, customMessage, targetPath, type, clean, restart) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
try {
|
|
197
|
+
console.log(tl.loc('Package deployment using OneDeploy initiated.'));
|
|
198
|
+
let queryParameters = [
|
|
199
|
+
'async=true',
|
|
200
|
+
'deployer=' + VSTS_ONE_DEPLOY
|
|
201
|
+
];
|
|
202
|
+
if (type) {
|
|
203
|
+
queryParameters.push('type=' + encodeURIComponent(type));
|
|
204
|
+
}
|
|
205
|
+
if (targetPath) {
|
|
206
|
+
queryParameters.push('path=' + encodeURIComponent(targetPath));
|
|
207
|
+
}
|
|
208
|
+
if (clean) {
|
|
209
|
+
queryParameters.push('clean=' + encodeURIComponent(clean));
|
|
210
|
+
}
|
|
211
|
+
if (restart) {
|
|
212
|
+
queryParameters.push('restart=' + encodeURIComponent(restart));
|
|
213
|
+
}
|
|
214
|
+
var deploymentMessage = this._getUpdateHistoryRequest(null, null, customMessage).message;
|
|
215
|
+
queryParameters.push('message=' + encodeURIComponent(deploymentMessage));
|
|
216
|
+
let deploymentDetails = yield this._appServiceKuduService.oneDeploy(packagePath, queryParameters);
|
|
217
|
+
console.log(tl.loc(deploymentDetails));
|
|
218
|
+
yield this._processDeploymentResponse(deploymentDetails);
|
|
219
|
+
console.log(tl.loc('Successfully deployed web package to App Service.'));
|
|
220
|
+
return deploymentDetails.id;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
tl.error(tl.loc('PackageDeploymentFailed'));
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
193
228
|
_processDeploymentResponse(deploymentDetails) {
|
|
194
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
230
|
try {
|
|
@@ -14,6 +14,7 @@ const physicalRootPath: string = '/site/wwwroot';
|
|
|
14
14
|
const deploymentFolder: string = 'site/deployments';
|
|
15
15
|
const manifestFileName: string = 'manifest';
|
|
16
16
|
const VSTS_ZIP_DEPLOY: string = 'VSTS_ZIP_DEPLOY';
|
|
17
|
+
const VSTS_ONE_DEPLOY: string = 'VSTS_ONE_DEPLOY';
|
|
17
18
|
const VSTS_DEPLOY: string = 'VSTS';
|
|
18
19
|
|
|
19
20
|
export class KuduServiceUtility {
|
|
@@ -196,6 +197,45 @@ export class KuduServiceUtility {
|
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
public async deployUsingOneDeploy(packagePath: string, customMessage?: any, targetPath?: any, type?: any, clean?: any, restart?: any): Promise<string> {
|
|
201
|
+
try {
|
|
202
|
+
console.log(tl.loc('Package deployment using OneDeploy initiated.'));
|
|
203
|
+
let queryParameters: Array<string> = [
|
|
204
|
+
'async=true',
|
|
205
|
+
'deployer=' + VSTS_ONE_DEPLOY
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
if (type) {
|
|
209
|
+
queryParameters.push('type=' + encodeURIComponent(type));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (targetPath) {
|
|
213
|
+
queryParameters.push('path=' + encodeURIComponent(targetPath));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (clean) {
|
|
217
|
+
queryParameters.push('clean=' + encodeURIComponent(clean));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (restart) {
|
|
221
|
+
queryParameters.push('restart=' + encodeURIComponent(restart));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var deploymentMessage = this._getUpdateHistoryRequest(null, null, customMessage).message;
|
|
225
|
+
queryParameters.push('message=' + encodeURIComponent(deploymentMessage));
|
|
226
|
+
let deploymentDetails = await this._appServiceKuduService.oneDeploy(packagePath, queryParameters);
|
|
227
|
+
console.log(tl.loc(deploymentDetails));
|
|
228
|
+
await this._processDeploymentResponse(deploymentDetails);
|
|
229
|
+
console.log(tl.loc('Successfully deployed web package to App Service.'));
|
|
230
|
+
|
|
231
|
+
return deploymentDetails.id;
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
tl.error(tl.loc('PackageDeploymentFailed'));
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
199
239
|
private async _processDeploymentResponse(deploymentDetails: any): Promise<void> {
|
|
200
240
|
try {
|
|
201
241
|
var kuduDeploymentDetails = await this._appServiceKuduService.getDeploymentDetails(deploymentDetails.id);
|
|
@@ -456,4 +496,4 @@ export class KuduServiceUtility {
|
|
|
456
496
|
deployer : 'VSTS'
|
|
457
497
|
};
|
|
458
498
|
}
|
|
459
|
-
}
|
|
499
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-pipelines-tasks-azurermdeploycommon",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.237.0",
|
|
4
4
|
"description": "Common Lib for Azure ARM REST apis",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"@types/q": "1.0.7",
|
|
22
22
|
"archiver": "2.1.1",
|
|
23
23
|
"azure-pipelines-task-lib": "^3.1.0",
|
|
24
|
-
"decompress-zip": "^0.3.3",
|
|
25
24
|
"jsonwebtoken": "^8.5.1",
|
|
26
25
|
"ltx": "2.6.2",
|
|
27
26
|
"node-stream-zip": "1.7.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Q = require('q');
|
|
2
|
-
export declare function unzip(zipLocation: any, unzipLocation: any): Promise<
|
|
2
|
+
export declare function unzip(zipLocation: any, unzipLocation: any): Promise<void>;
|
|
3
3
|
export declare function archiveFolder(folderPath: any, targetPath: any, zipName: any): Promise<unknown>;
|
|
4
4
|
/**
|
|
5
5
|
* Returns array of files present in archived package
|
|
@@ -14,8 +14,7 @@ const tl = require("azure-pipelines-task-lib/task");
|
|
|
14
14
|
const path = require("path");
|
|
15
15
|
const Q = require("q");
|
|
16
16
|
const fs = require("fs");
|
|
17
|
-
const
|
|
18
|
-
var DecompressZip = require('decompress-zip');
|
|
17
|
+
const node_stream_zip_1 = require("node-stream-zip");
|
|
19
18
|
var archiver = require('archiver');
|
|
20
19
|
function unzip(zipLocation, unzipLocation) {
|
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -23,19 +22,15 @@ function unzip(zipLocation, unzipLocation) {
|
|
|
23
22
|
if (tl.exist(unzipLocation)) {
|
|
24
23
|
tl.rmRF(unzipLocation);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
tl.mkdirP(unzipLocation);
|
|
26
|
+
const zip = new node_stream_zip_1.default.async({ file: zipLocation });
|
|
27
|
+
zip.extract(null, unzipLocation).then(() => {
|
|
28
|
+
zip.close();
|
|
29
|
+
defer.resolve();
|
|
30
|
+
}).catch((error) => {
|
|
31
|
+
console.log(`error extracting ${zipLocation}: ${error}`);
|
|
29
32
|
defer.reject(error);
|
|
30
33
|
});
|
|
31
|
-
unzipper.on('extract', function (log) {
|
|
32
|
-
tl.debug('extracted ' + zipLocation + ' to ' + unzipLocation + ' Successfully');
|
|
33
|
-
defer.resolve(unzipLocation);
|
|
34
|
-
});
|
|
35
|
-
unzipper.extract({
|
|
36
|
-
path: unzipLocation
|
|
37
|
-
});
|
|
38
|
-
return defer.promise;
|
|
39
34
|
});
|
|
40
35
|
}
|
|
41
36
|
exports.unzip = unzip;
|
|
@@ -66,17 +61,16 @@ exports.archiveFolder = archiveFolder;
|
|
|
66
61
|
function getArchivedEntries(archivedPackage) {
|
|
67
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
63
|
var deferred = Q.defer();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
unzipper.on('list', function (files) {
|
|
74
|
-
var packageComponent = {
|
|
75
|
-
"entries": files
|
|
64
|
+
const zip = new node_stream_zip_1.default.async({ file: archivedPackage });
|
|
65
|
+
zip.entries().then(entries => {
|
|
66
|
+
var packageConmponent = {
|
|
67
|
+
'entries': Object.keys(entries)
|
|
76
68
|
};
|
|
77
|
-
|
|
69
|
+
zip.close();
|
|
70
|
+
deferred.resolve(packageConmponent);
|
|
71
|
+
}).catch(error => {
|
|
72
|
+
deferred.reject(error);
|
|
78
73
|
});
|
|
79
|
-
unzipper.list();
|
|
80
74
|
return deferred.promise;
|
|
81
75
|
});
|
|
82
76
|
}
|
|
@@ -86,7 +80,7 @@ function checkIfFilesExistsInZip(archivedPackage, files) {
|
|
|
86
80
|
for (let i = 0; i < files.length; i++) {
|
|
87
81
|
files[i] = files[i].toLowerCase();
|
|
88
82
|
}
|
|
89
|
-
const zip = new
|
|
83
|
+
const zip = new node_stream_zip_1.default({
|
|
90
84
|
file: archivedPackage,
|
|
91
85
|
storeEntries: true,
|
|
92
86
|
skipEntryNameValidation: true
|
|
@@ -2,8 +2,7 @@ import tl = require('azure-pipelines-task-lib/task');
|
|
|
2
2
|
import path = require('path');
|
|
3
3
|
import Q = require('q');
|
|
4
4
|
import fs = require('fs');
|
|
5
|
-
import StreamZip
|
|
6
|
-
var DecompressZip = require('decompress-zip');
|
|
5
|
+
import StreamZip from 'node-stream-zip';
|
|
7
6
|
var archiver = require('archiver');
|
|
8
7
|
|
|
9
8
|
export async function unzip(zipLocation, unzipLocation) {
|
|
@@ -11,19 +10,15 @@ export async function unzip(zipLocation, unzipLocation) {
|
|
|
11
10
|
if(tl.exist(unzipLocation)) {
|
|
12
11
|
tl.rmRF(unzipLocation);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
unzipper.extract({
|
|
24
|
-
path: unzipLocation
|
|
25
|
-
});
|
|
26
|
-
return defer.promise;
|
|
13
|
+
tl.mkdirP(unzipLocation);
|
|
14
|
+
const zip = new StreamZip.async({ file: zipLocation});
|
|
15
|
+
zip.extract(null, unzipLocation).then(() => {
|
|
16
|
+
zip.close();
|
|
17
|
+
defer.resolve();
|
|
18
|
+
}).catch((error) => {
|
|
19
|
+
console.log(`error extracting ${zipLocation}: ${error}`);
|
|
20
|
+
defer.reject(error);
|
|
21
|
+
})
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
export async function archiveFolder(folderPath, targetPath, zipName) {
|
|
@@ -53,17 +48,16 @@ export async function archiveFolder(folderPath, targetPath, zipName) {
|
|
|
53
48
|
*/
|
|
54
49
|
export async function getArchivedEntries(archivedPackage: string) {
|
|
55
50
|
var deferred = Q.defer();
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const zip = new StreamZip.async({file: archivedPackage});
|
|
52
|
+
zip.entries().then(entries => {
|
|
53
|
+
var packageConmponent = {
|
|
54
|
+
'entries': Object.keys(entries)
|
|
55
|
+
}
|
|
56
|
+
zip.close();
|
|
57
|
+
deferred.resolve(packageConmponent);
|
|
58
|
+
}).catch(error => {
|
|
58
59
|
deferred.reject(error);
|
|
59
|
-
})
|
|
60
|
-
unzipper.on('list', function (files) {
|
|
61
|
-
var packageComponent = {
|
|
62
|
-
"entries":files
|
|
63
|
-
};
|
|
64
|
-
deferred.resolve(packageComponent);
|
|
65
|
-
});
|
|
66
|
-
unzipper.list();
|
|
60
|
+
})
|
|
67
61
|
return deferred.promise;
|
|
68
62
|
}
|
|
69
63
|
|