artifact-engine 1.273.0 → 1.282.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/Engine/artifactEngine.d.ts +2 -0
- package/Engine/artifactEngine.js +34 -11
- package/Engine/artifactEngineOptions.d.ts +2 -0
- package/Engine/artifactEngineOptions.js +1 -0
- package/Engine/logger.d.ts +8 -0
- package/Engine/logger.js +31 -2
- package/Models/artifactprovider.d.ts +1 -0
- package/Providers/filesystemCaseSensitivity.d.ts +13 -0
- package/Providers/filesystemCaseSensitivity.js +68 -0
- package/Providers/filesystemProvider.d.ts +3 -0
- package/Providers/filesystemProvider.js +35 -4
- package/Providers/jenkins.handlebars +10 -10
- package/Providers/teamcity.handlebars +24 -24
- package/Providers/typed-rest-client/opensource/node-http-ntlm/ntlm.js +389 -389
- package/Providers/vsts.handlebars +15 -15
- package/Providers/webProvider.d.ts +1 -0
- package/Providers/webProvider.js +8 -3
- package/README.md +90 -39
- package/Strings/resources.resjson/de-DE/resources.resjson +12 -11
- package/Strings/resources.resjson/en-US/resources.resjson +12 -11
- package/Strings/resources.resjson/es-ES/resources.resjson +12 -11
- package/Strings/resources.resjson/fr-FR/resources.resjson +12 -11
- package/Strings/resources.resjson/it-IT/resources.resjson +12 -11
- package/Strings/resources.resjson/ja-JP/resources.resjson +12 -11
- package/Strings/resources.resjson/ko-KR/resources.resjson +12 -11
- package/Strings/resources.resjson/ru-RU/resources.resjson +12 -11
- package/Strings/resources.resjson/zh-CN/resources.resjson +12 -11
- package/Strings/resources.resjson/zh-TW/resources.resjson +12 -11
- package/ThirdPartyNotices.txt +925 -925
- package/lib.json +14 -13
- package/package.json +63 -63
- package/Providers/typed-rest-client/opensource/node-http-ntlm/readme.txt +0 -6
|
@@ -4,9 +4,11 @@ export declare class ArtifactEngine {
|
|
|
4
4
|
processItems(sourceProvider: models.IArtifactProvider, destProvider: models.IArtifactProvider, artifactEngineOptions?: ArtifactEngineOptions): Promise<models.ArtifactDownloadTicket[]>;
|
|
5
5
|
processArtifactItem(sourceProvider: models.IArtifactProvider, item: models.ArtifactItem, destProvider: models.IArtifactProvider, artifactEngineOptions: ArtifactEngineOptions): Promise<void>;
|
|
6
6
|
processArtifactItemImplementation(sourceProvider: models.IArtifactProvider, item: models.ArtifactItem, destProvider: models.IArtifactProvider, artifactEngineOptions: ArtifactEngineOptions, resolve: any, reject: any, retryCount?: number): void;
|
|
7
|
+
private isCaseInsensitiveArtifactMatchingEnabled;
|
|
7
8
|
private getRetryIntervalInSeconds;
|
|
8
9
|
createPatternList(artifactEngineOptions: ArtifactEngineOptions): void;
|
|
9
10
|
private artifactItemStore;
|
|
10
11
|
private logger;
|
|
11
12
|
private patternList;
|
|
13
|
+
private isCaseInsensitiveArtifactMatching;
|
|
12
14
|
}
|
package/Engine/artifactEngine.js
CHANGED
|
@@ -12,14 +12,19 @@ const worker_1 = require("./worker");
|
|
|
12
12
|
class ArtifactEngine {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.artifactItemStore = new artifactItemStore_1.ArtifactItemStore();
|
|
15
|
+
this.isCaseInsensitiveArtifactMatching = false;
|
|
15
16
|
}
|
|
16
17
|
processItems(sourceProvider, destProvider, artifactEngineOptions) {
|
|
17
18
|
var artifactDownloadTicketsPromise = new Promise((resolve, reject) => {
|
|
19
|
+
var _a;
|
|
18
20
|
const workers = [];
|
|
19
21
|
artifactEngineOptions = artifactEngineOptions || new artifactEngineOptions_1.ArtifactEngineOptions();
|
|
20
22
|
this.createPatternList(artifactEngineOptions);
|
|
23
|
+
this.isCaseInsensitiveArtifactMatching =
|
|
24
|
+
this.isCaseInsensitiveArtifactMatchingEnabled(destProvider);
|
|
21
25
|
this.artifactItemStore.flush();
|
|
22
26
|
logger_1.Logger.verbose = artifactEngineOptions.verbose;
|
|
27
|
+
logger_1.Logger.vsoCommandMode = (_a = artifactEngineOptions.vsoCommandMode) !== null && _a !== void 0 ? _a : 'disabled';
|
|
23
28
|
this.logger = new logger_1.Logger(this.artifactItemStore);
|
|
24
29
|
this.logger.logProgress();
|
|
25
30
|
sourceProvider.artifactItemStore = this.artifactItemStore;
|
|
@@ -63,7 +68,7 @@ class ArtifactEngine {
|
|
|
63
68
|
}
|
|
64
69
|
else {
|
|
65
70
|
this.artifactItemStore.increaseRetryCount(item);
|
|
66
|
-
logger_1.Logger.
|
|
71
|
+
logger_1.Logger.messageExternalOutput(tl.loc("RetryingDownload", item.path, (retryCount + 1)));
|
|
67
72
|
// retry interval sequence 5s 15s 45s 135s
|
|
68
73
|
// 2 min is the time limit for freeing of ports
|
|
69
74
|
setTimeout(() => this
|
|
@@ -79,7 +84,7 @@ class ArtifactEngine {
|
|
|
79
84
|
noglobstar: false,
|
|
80
85
|
dot: true,
|
|
81
86
|
noext: false,
|
|
82
|
-
nocase:
|
|
87
|
+
nocase: this.isCaseInsensitiveArtifactMatching,
|
|
83
88
|
nonull: false,
|
|
84
89
|
matchBase: false,
|
|
85
90
|
nocomment: false,
|
|
@@ -87,24 +92,24 @@ class ArtifactEngine {
|
|
|
87
92
|
flipNegate: false
|
|
88
93
|
};
|
|
89
94
|
if (tl.match([pathToMatch], this.patternList, null, matchOptions).length > 0) {
|
|
90
|
-
logger_1.Logger.
|
|
95
|
+
logger_1.Logger.infoExternalOutput("Processing " + item.path);
|
|
91
96
|
sourceProvider.getArtifactItem(item).then((contentStream) => {
|
|
92
|
-
logger_1.Logger.
|
|
97
|
+
logger_1.Logger.infoExternalOutput("Got download stream for item: " + item.path);
|
|
93
98
|
destProvider.putArtifactItem(item, contentStream)
|
|
94
99
|
.then((item) => {
|
|
95
100
|
this.artifactItemStore.updateState(item, models.TicketState.Processed);
|
|
96
101
|
resolve();
|
|
97
102
|
}, (err) => {
|
|
98
|
-
logger_1.Logger.
|
|
103
|
+
logger_1.Logger.infoExternalOutput("Error placing file " + item.path + ": " + err);
|
|
99
104
|
retryIfRequired(err);
|
|
100
105
|
});
|
|
101
106
|
}, (err) => {
|
|
102
|
-
logger_1.Logger.
|
|
107
|
+
logger_1.Logger.infoExternalOutput("Error getting file " + item.path + ": " + err);
|
|
103
108
|
retryIfRequired(err);
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
else {
|
|
107
|
-
logger_1.Logger.
|
|
112
|
+
logger_1.Logger.messageExternalOutput(tl.loc("SkippingItem", pathToMatch));
|
|
108
113
|
this.artifactItemStore.updateState(item, models.TicketState.Skipped);
|
|
109
114
|
resolve();
|
|
110
115
|
}
|
|
@@ -127,18 +132,36 @@ class ArtifactEngine {
|
|
|
127
132
|
this.artifactItemStore.updateState(item, models.TicketState.Processed);
|
|
128
133
|
resolve();
|
|
129
134
|
}, (err) => {
|
|
130
|
-
logger_1.Logger.
|
|
135
|
+
logger_1.Logger.infoExternalOutput("Error creating folder " + item.path + ": " + err);
|
|
131
136
|
retryIfRequired(err);
|
|
132
137
|
});
|
|
133
138
|
}
|
|
134
139
|
logger_1.Logger.logInfo("Enqueued " + items.length + " for processing.");
|
|
135
140
|
resolve();
|
|
136
141
|
}, (err) => {
|
|
137
|
-
logger_1.Logger.
|
|
142
|
+
logger_1.Logger.infoExternalOutput("Error getting " + item.path + ":" + err);
|
|
138
143
|
retryIfRequired(err);
|
|
139
144
|
});
|
|
140
145
|
}
|
|
141
146
|
}
|
|
147
|
+
isCaseInsensitiveArtifactMatchingEnabled(destProvider) {
|
|
148
|
+
if (!tl.getPipelineFeature('CaseInsensitiveArtifactMatchingFixEnabled')) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (process.platform === 'win32') {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (process.platform !== 'darwin' || !destProvider.isCaseInsensitiveFilesystem) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
return destProvider.isCaseInsensitiveFilesystem();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
// Filesystem detection is advisory; preserve case-sensitive matching if it cannot run.
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
142
165
|
getRetryIntervalInSeconds(baseRetryInterval, retryCount) {
|
|
143
166
|
let MaxRetryLimitInSeconds = 360;
|
|
144
167
|
var exponentialBackOff = baseRetryInterval * Math.pow(3, (retryCount + 1));
|
|
@@ -157,11 +180,11 @@ exports.ArtifactEngine = ArtifactEngine;
|
|
|
157
180
|
tl.setResourcePath(path.join(path.dirname(__dirname), 'lib.json'));
|
|
158
181
|
process.on('unhandledRejection', (err) => {
|
|
159
182
|
ci.publishEvent('reliability', { issueType: 'unhandledRejection', errorMessage: JSON.stringify(err, Object.getOwnPropertyNames(err)) });
|
|
160
|
-
logger_1.Logger.
|
|
183
|
+
logger_1.Logger.errorExternalOutput(tl.loc("UnhandledRejection", err));
|
|
161
184
|
throw err;
|
|
162
185
|
});
|
|
163
186
|
process.on('uncaughtException', (err) => {
|
|
164
187
|
ci.publishEvent('reliability', { issueType: 'uncaughtException', errorMessage: JSON.stringify(err, Object.getOwnPropertyNames(err)) });
|
|
165
|
-
logger_1.Logger.
|
|
188
|
+
logger_1.Logger.errorExternalOutput(tl.loc("UnhandledException", err));
|
|
166
189
|
throw err;
|
|
167
190
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VsoCommandMode } from 'azure-pipelines-task-lib/externaloutput';
|
|
1
2
|
export declare class ArtifactEngineOptions {
|
|
2
3
|
retryLimit: number;
|
|
3
4
|
retryIntervalInSeconds: number;
|
|
@@ -5,4 +6,5 @@ export declare class ArtifactEngineOptions {
|
|
|
5
6
|
parallelProcessingLimit: number;
|
|
6
7
|
itemPattern: string;
|
|
7
8
|
verbose: boolean;
|
|
9
|
+
vsoCommandMode?: VsoCommandMode;
|
|
8
10
|
}
|
package/Engine/logger.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { VsoCommandMode } from 'azure-pipelines-task-lib/externaloutput';
|
|
1
2
|
import { ArtifactItemStore } from '../Store/artifactItemStore';
|
|
2
3
|
export declare class Logger {
|
|
3
4
|
constructor(store: ArtifactItemStore);
|
|
4
5
|
static logInfo(message: string): void;
|
|
5
6
|
static logError(message: string): void;
|
|
6
7
|
static logMessage(message: string): void;
|
|
8
|
+
/** Logs external text while preserving debug output semantics. */
|
|
9
|
+
static infoExternalOutput(message: string): void;
|
|
10
|
+
/** Logs external text while preserving error output semantics. */
|
|
11
|
+
static errorExternalOutput(message: string): void;
|
|
12
|
+
/** Logs external text rather than trusted internal messages or agent commands. */
|
|
13
|
+
static messageExternalOutput(message: string): void;
|
|
7
14
|
logProgress(): void;
|
|
8
15
|
logSummary(): void;
|
|
9
16
|
private padText;
|
|
10
17
|
static verbose: boolean;
|
|
18
|
+
static vsoCommandMode: VsoCommandMode;
|
|
11
19
|
private store;
|
|
12
20
|
private startTime;
|
|
13
21
|
}
|
package/Engine/logger.js
CHANGED
|
@@ -10,10 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Logger = void 0;
|
|
13
|
+
const tl = require("azure-pipelines-task-lib/task");
|
|
13
14
|
const Models_1 = require("../Models");
|
|
14
15
|
const ticketState_1 = require("../Models/ticketState");
|
|
15
|
-
var tl = require('azure-pipelines-task-lib');
|
|
16
16
|
const ci = require("./cilogger");
|
|
17
|
+
const externalOutputFeature = 'EnableArtifactEngineExternalOutput';
|
|
17
18
|
class Logger {
|
|
18
19
|
constructor(store) {
|
|
19
20
|
this.store = store;
|
|
@@ -28,6 +29,33 @@ class Logger {
|
|
|
28
29
|
static logMessage(message) {
|
|
29
30
|
console.log(message);
|
|
30
31
|
}
|
|
32
|
+
/** Logs external text while preserving debug output semantics. */
|
|
33
|
+
static infoExternalOutput(message) {
|
|
34
|
+
if (tl.getPipelineFeature(externalOutputFeature)) {
|
|
35
|
+
tl.debugExternalOutput(message, { source: 'remote', vsoCommandMode: Logger.vsoCommandMode });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
Logger.logInfo(message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Logs external text while preserving error output semantics. */
|
|
42
|
+
static errorExternalOutput(message) {
|
|
43
|
+
if (tl.getPipelineFeature(externalOutputFeature)) {
|
|
44
|
+
tl.errorExternalOutput(message, { source: 'remote', vsoCommandMode: Logger.vsoCommandMode });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
Logger.logError(message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Logs external text rather than trusted internal messages or agent commands. */
|
|
51
|
+
static messageExternalOutput(message) {
|
|
52
|
+
if (tl.getPipelineFeature(externalOutputFeature)) {
|
|
53
|
+
tl.writeExternalOutput(message + '\n', { source: 'remote', vsoCommandMode: Logger.vsoCommandMode });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
Logger.logMessage(message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
31
59
|
logProgress() {
|
|
32
60
|
if (Logger.verbose) {
|
|
33
61
|
var progressLogger = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -96,7 +124,7 @@ class Logger {
|
|
|
96
124
|
tl.debug(this.padText("", maxPathLength + 25 + 25 + 10 + 10 + 15, '-'));
|
|
97
125
|
fileTickets.forEach(ticket => {
|
|
98
126
|
var duration = (ticket.finishTime.valueOf() - ticket.startTime.valueOf()) / 1000 + " secs";
|
|
99
|
-
|
|
127
|
+
Logger.infoExternalOutput("| " + this.padText(ticket.artifactItem.path, maxPathLength) + " | " + this.padText(ticket.startTime.toISOString(), 25) + " | " + this.padText(ticket.finishTime.toISOString(), 25) + " | " + this.padText(duration, 10) + " | " + this.padText(ticket.state.toString().toUpperCase(), 10) + "|");
|
|
100
128
|
tl.debug(this.padText("", maxPathLength + 25 + 25 + 10 + 10 + 15, '-'));
|
|
101
129
|
});
|
|
102
130
|
}
|
|
@@ -109,3 +137,4 @@ class Logger {
|
|
|
109
137
|
}
|
|
110
138
|
}
|
|
111
139
|
exports.Logger = Logger;
|
|
140
|
+
Logger.vsoCommandMode = 'disabled';
|
|
@@ -7,5 +7,6 @@ export interface IArtifactProvider {
|
|
|
7
7
|
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>;
|
|
8
8
|
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
9
9
|
putArtifactItem(artifactItem: ArtifactItem, stream: NodeJS.ReadableStream): Promise<ArtifactItem>;
|
|
10
|
+
isCaseInsensitiveFilesystem?(): boolean;
|
|
10
11
|
dispose(): void;
|
|
11
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface FileSystemCaseSensitivityProbe {
|
|
2
|
+
existsSync(path: string): boolean;
|
|
3
|
+
readdirSync(path: string): string[];
|
|
4
|
+
statSync(path: string): {
|
|
5
|
+
dev: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface PathOperations {
|
|
9
|
+
resolve(...paths: string[]): string;
|
|
10
|
+
dirname(path: string): string;
|
|
11
|
+
join(...paths: string[]): string;
|
|
12
|
+
}
|
|
13
|
+
export declare function isFilesystemCaseInsensitive(destinationPath: string, fileSystem?: FileSystemCaseSensitivityProbe, pathOperations?: PathOperations): boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFilesystemCaseInsensitive = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
// Detect case behavior without creating a probe file. Probe only inside the nearest existing
|
|
7
|
+
// destination ancestor. Empty directories may ascend only within the same device.
|
|
8
|
+
function isFilesystemCaseInsensitive(destinationPath, fileSystem = fs, pathOperations = path) {
|
|
9
|
+
if (!destinationPath) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
let existingPath = pathOperations.resolve(destinationPath);
|
|
14
|
+
while (true) {
|
|
15
|
+
if (fileSystem.existsSync(existingPath)) {
|
|
16
|
+
const caseSensitivity = probeDirectoryCaseSensitivity(existingPath, fileSystem, pathOperations);
|
|
17
|
+
if (caseSensitivity !== null) {
|
|
18
|
+
return caseSensitivity;
|
|
19
|
+
}
|
|
20
|
+
const parentPath = pathOperations.dirname(existingPath);
|
|
21
|
+
if (parentPath === existingPath) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (fileSystem.statSync(existingPath).dev !== fileSystem.statSync(parentPath).dev) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
existingPath = parentPath;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const parentPath = pathOperations.dirname(existingPath);
|
|
31
|
+
if (parentPath === existingPath) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
existingPath = parentPath;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// A false negative only retains the original case-sensitive behavior.
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.isFilesystemCaseInsensitive = isFilesystemCaseInsensitive;
|
|
43
|
+
function probeDirectoryCaseSensitivity(directoryPath, fileSystem, pathOperations) {
|
|
44
|
+
const entries = fileSystem.readdirSync(directoryPath);
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
const caseVariant = getCaseVariant(entry);
|
|
47
|
+
if (!caseVariant) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (entries.filter((candidate) => candidate.toLowerCase() === entry.toLowerCase()).length !== 1) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return fileSystem.existsSync(pathOperations.join(directoryPath, caseVariant));
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function getCaseVariant(pathSegment) {
|
|
58
|
+
for (let index = 0; index < pathSegment.length; index++) {
|
|
59
|
+
const character = pathSegment.charAt(index);
|
|
60
|
+
if (character >= 'a' && character <= 'z') {
|
|
61
|
+
return pathSegment.substring(0, index) + character.toUpperCase() + pathSegment.substring(index + 1);
|
|
62
|
+
}
|
|
63
|
+
if (character >= 'A' && character <= 'Z') {
|
|
64
|
+
return pathSegment.substring(0, index) + character.toLowerCase() + pathSegment.substring(index + 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
@@ -8,8 +8,11 @@ export declare class FilesystemProvider implements models.IArtifactProvider {
|
|
|
8
8
|
getArtifactItems(artifactItem: models.ArtifactItem): Promise<models.ArtifactItem[]>;
|
|
9
9
|
getArtifactItem(artifactItem: models.ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
10
10
|
putArtifactItem(item: models.ArtifactItem, stream: NodeJS.ReadableStream): Promise<models.ArtifactItem>;
|
|
11
|
+
isCaseInsensitiveFilesystem(): boolean;
|
|
11
12
|
dispose(): void;
|
|
12
13
|
private getItems;
|
|
13
14
|
private _rootLocation;
|
|
14
15
|
private _rootItemPath;
|
|
16
|
+
private _hasDeterminedFilesystemCaseSensitivity;
|
|
17
|
+
private _isCaseInsensitiveFilesystem;
|
|
15
18
|
}
|
|
@@ -5,9 +5,12 @@ const path = require("path");
|
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const models = require("../Models");
|
|
7
7
|
const logger_1 = require("../Engine/logger");
|
|
8
|
+
const filesystemCaseSensitivity_1 = require("./filesystemCaseSensitivity");
|
|
8
9
|
var tl = require('azure-pipelines-task-lib');
|
|
9
10
|
class FilesystemProvider {
|
|
10
11
|
constructor(rootLocation, rootItemPath) {
|
|
12
|
+
this._hasDeterminedFilesystemCaseSensitivity = false;
|
|
13
|
+
this._isCaseInsensitiveFilesystem = false;
|
|
11
14
|
this._rootLocation = rootLocation;
|
|
12
15
|
this._rootItemPath = rootItemPath ? rootItemPath : '';
|
|
13
16
|
}
|
|
@@ -43,17 +46,33 @@ class FilesystemProvider {
|
|
|
43
46
|
}
|
|
44
47
|
putArtifactItem(item, stream) {
|
|
45
48
|
return new Promise((resolve, reject) => {
|
|
46
|
-
|
|
49
|
+
let outputItemPath;
|
|
50
|
+
if (!tl.getPipelineFeature("EnableArtifactEnginePathValidation")) {
|
|
51
|
+
outputItemPath = path.join(this._rootLocation, item.path);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Feature on: reject item paths that resolve outside the download root.
|
|
55
|
+
const resolvedRoot = path.resolve(this._rootLocation);
|
|
56
|
+
const resolvedTarget = path.resolve(resolvedRoot, item.path);
|
|
57
|
+
const relative = path.relative(resolvedRoot, resolvedTarget);
|
|
58
|
+
if (relative === '..'
|
|
59
|
+
|| relative.startsWith('..' + path.sep)
|
|
60
|
+
|| path.isAbsolute(relative)) {
|
|
61
|
+
reject(new Error(tl.loc("InvalidArtifactPath", item.path)));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
outputItemPath = resolvedTarget;
|
|
65
|
+
}
|
|
47
66
|
if (item.itemType === models.ItemType.File) {
|
|
48
67
|
const folder = path.dirname(outputItemPath);
|
|
49
68
|
try {
|
|
50
69
|
// create parent folder if it has not already been created
|
|
51
70
|
tl.mkdirP(folder);
|
|
52
|
-
logger_1.Logger.
|
|
71
|
+
logger_1.Logger.messageExternalOutput(tl.loc("DownloadingTo", item.path, outputItemPath));
|
|
53
72
|
const outputStream = fs.createWriteStream(outputItemPath);
|
|
54
73
|
stream.pipe(outputStream);
|
|
55
74
|
stream.on("end", () => {
|
|
56
|
-
logger_1.Logger.
|
|
75
|
+
logger_1.Logger.messageExternalOutput(tl.loc("DownloadedTo", item.path, outputItemPath));
|
|
57
76
|
if (!item.metadata) {
|
|
58
77
|
item.metadata = {};
|
|
59
78
|
}
|
|
@@ -82,6 +101,18 @@ class FilesystemProvider {
|
|
|
82
101
|
}
|
|
83
102
|
});
|
|
84
103
|
}
|
|
104
|
+
isCaseInsensitiveFilesystem() {
|
|
105
|
+
if (!this._hasDeterminedFilesystemCaseSensitivity) {
|
|
106
|
+
try {
|
|
107
|
+
this._isCaseInsensitiveFilesystem = (0, filesystemCaseSensitivity_1.isFilesystemCaseInsensitive)(this._rootLocation);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
this._isCaseInsensitiveFilesystem = false;
|
|
111
|
+
}
|
|
112
|
+
this._hasDeterminedFilesystemCaseSensitivity = true;
|
|
113
|
+
}
|
|
114
|
+
return this._isCaseInsensitiveFilesystem;
|
|
115
|
+
}
|
|
85
116
|
dispose() {
|
|
86
117
|
}
|
|
87
118
|
getItems(itemsPath, parentRelativePath) {
|
|
@@ -89,7 +120,7 @@ class FilesystemProvider {
|
|
|
89
120
|
var items = [];
|
|
90
121
|
fs.readdir(itemsPath, (error, files) => {
|
|
91
122
|
if (!!error) {
|
|
92
|
-
logger_1.Logger.
|
|
123
|
+
logger_1.Logger.messageExternalOutput(tl.loc("UnableToReadDirectory", itemsPath, error));
|
|
93
124
|
reject(error);
|
|
94
125
|
return;
|
|
95
126
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
{{#artifacts}}
|
|
3
|
-
{
|
|
4
|
-
"path" : "{{this.relativePath}}",
|
|
5
|
-
"itemType": "file",
|
|
6
|
-
"metadata" : {
|
|
7
|
-
"downloadUrl": "{{../endpoint.url}}/job/{{../definition}}/{{../version}}/artifact/{{this.relativePath}}"
|
|
8
|
-
}
|
|
9
|
-
}{{#unless @last}},{{/unless}}
|
|
10
|
-
{{/artifacts}}
|
|
1
|
+
[
|
|
2
|
+
{{#artifacts}}
|
|
3
|
+
{
|
|
4
|
+
"path" : "{{this.relativePath}}",
|
|
5
|
+
"itemType": "file",
|
|
6
|
+
"metadata" : {
|
|
7
|
+
"downloadUrl": "{{../endpoint.url}}/job/{{../definition}}/{{../version}}/artifact/{{this.relativePath}}"
|
|
8
|
+
}
|
|
9
|
+
}{{#unless @last}},{{/unless}}
|
|
10
|
+
{{/artifacts}}
|
|
11
11
|
]
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
[
|
|
2
|
-
{{#file}}
|
|
3
|
-
{
|
|
4
|
-
"path": "{{this.name}}",
|
|
5
|
-
"lastModified": "{{this.modificationTime}}",
|
|
6
|
-
{{#if size}}
|
|
7
|
-
"fileLength" : "{{this.size}}",
|
|
8
|
-
{{/if}}
|
|
9
|
-
{{#if children}}
|
|
10
|
-
"itemType": "folder",
|
|
11
|
-
{{/if}}
|
|
12
|
-
{{#if content}}
|
|
13
|
-
"itemType": "file",
|
|
14
|
-
{{/if}}
|
|
15
|
-
"metadata": {
|
|
16
|
-
{{#if content}}
|
|
17
|
-
"downloadUrl" : "{{../endpoint.url}}{{content.href}}"
|
|
18
|
-
{{/if}}
|
|
19
|
-
{{#if children}}
|
|
20
|
-
"downloadUrl": "{{../endpoint.url}}{{children.href}}"
|
|
21
|
-
{{/if}}
|
|
22
|
-
}
|
|
23
|
-
}{{#unless @last}},{{/unless}}
|
|
24
|
-
{{/file}}
|
|
1
|
+
[
|
|
2
|
+
{{#file}}
|
|
3
|
+
{
|
|
4
|
+
"path": "{{this.name}}",
|
|
5
|
+
"lastModified": "{{this.modificationTime}}",
|
|
6
|
+
{{#if size}}
|
|
7
|
+
"fileLength" : "{{this.size}}",
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if children}}
|
|
10
|
+
"itemType": "folder",
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if content}}
|
|
13
|
+
"itemType": "file",
|
|
14
|
+
{{/if}}
|
|
15
|
+
"metadata": {
|
|
16
|
+
{{#if content}}
|
|
17
|
+
"downloadUrl" : "{{../endpoint.url}}{{content.href}}"
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if children}}
|
|
20
|
+
"downloadUrl": "{{../endpoint.url}}{{children.href}}"
|
|
21
|
+
{{/if}}
|
|
22
|
+
}
|
|
23
|
+
}{{#unless @last}},{{/unless}}
|
|
24
|
+
{{/file}}
|
|
25
25
|
]
|