Skip to content

Commit 05a5e39

Browse files
authored
Fix issues with download tasks. (#6198)
* Using local copy of vso-node-api. (#6116) * Fix broken url resolution. (#6127) * Fix issues with encoding. (#6187) * Fix container path encoding while downloading artifacts. * Fix artifact download transform filenames with "=" into &#x3D * bump jenkins download task version * update artifact engine version for download tasks.
1 parent 63a40a6 commit 05a5e39

27 files changed

+9702
-17
lines changed

Tasks/DownloadBuildArtifacts/main.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ var url = require('url');
33
var fs = require('fs');
44

55
import * as tl from 'vsts-task-lib/task';
6-
import { IBuildApi } from 'vso-node-api/BuildApi';
7-
import { IRequestHandler } from 'vso-node-api/interfaces/common/VsoBaseInterfaces';
8-
import { WebApi, getHandlerFromToken } from 'vso-node-api/WebApi';
6+
import { IBuildApi } from './vso-node-api/BuildApi';
7+
import { IRequestHandler } from './vso-node-api/interfaces/common/VsoBaseInterfaces';
8+
import { WebApi, getHandlerFromToken } from './vso-node-api/WebApi';
99

1010
import * as models from 'artifact-engine/Models';
1111
import * as engine from 'artifact-engine/Engine';
@@ -149,7 +149,7 @@ async function main(): Promise<void> {
149149
var containerId: number = parseInt(containerParts[1]);
150150
var containerPath: string = containerParts[2];
151151

152-
var itemsUrl = endpointUrl + "/_apis/resources/Containers/" + containerId + "?itemPath=" + containerPath + "&isShallow=true&api-version=4.1-preview.4";
152+
var itemsUrl = endpointUrl + "/_apis/resources/Containers/" + containerId + "?itemPath=" + encodeURIComponent(containerPath) + "&isShallow=true&api-version=4.1-preview.4";
153153
console.log(tl.loc("DownloadArtifacts", itemsUrl));
154154

155155
var variables = {};
@@ -163,7 +163,7 @@ async function main(): Promise<void> {
163163
}
164164
else if (artifact.resource.type.toLowerCase() === "filepath") {
165165
let downloader = new engine.ArtifactEngine();
166-
let downloadUrl = decodeURI(artifact.resource.downloadUrl.replace("file:", ""));
166+
let downloadUrl = decodeURIComponent(artifact.resource.downloadUrl.replace("file:", ""));
167167
let artifactLocation = downloadUrl + '/' + artifact.name;
168168
if (!fs.existsSync(artifactLocation)) {
169169
console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));

Tasks/DownloadBuildArtifacts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"dependencies": {
2020
"vsts-task-lib": "2.1.0",
2121
"vso-node-api": "^6.2.8-preview",
22-
"artifact-engine": "0.1.14"
22+
"artifact-engine": "0.1.15"
2323
}
2424
}

Tasks/DownloadBuildArtifacts/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 0,
1212
"Minor": 127,
13-
"Patch": 5
13+
"Patch": 6
1414
},
1515
"groups": [
1616
{

Tasks/DownloadBuildArtifacts/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 0,
1212
"Minor": 127,
13-
"Patch": 5
13+
"Patch": 6
1414
},
1515
"groups": [
1616
{

Tasks/DownloadBuildArtifacts/vso-node-api/BuildApi.ts

Lines changed: 3033 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
import vsom = require('./VsoClient');
5+
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
6+
import serm = require('./Serialization');
7+
import * as rm from 'artifact-engine/Providers/typed-rest-client/RestClient';
8+
import * as hm from 'artifact-engine/Providers/typed-rest-client/HttpClient';
9+
10+
export class ClientApiBase {
11+
baseUrl: string;
12+
userAgent: string;
13+
http: hm.HttpClient;
14+
rest: rm.RestClient;
15+
16+
vsoClient: vsom.VsoClient;
17+
18+
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], userAgent?: string, options?: VsoBaseInterfaces.IRequestOptions);
19+
20+
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], userAgent: string, options?: VsoBaseInterfaces.IRequestOptions) {
21+
this.baseUrl = baseUrl;
22+
23+
this.http = new hm.HttpClient(userAgent, handlers, options);
24+
this.rest = new rm.RestClient(userAgent, null, handlers, options);
25+
26+
this.vsoClient = new vsom.VsoClient(baseUrl, this.rest);
27+
this.userAgent = userAgent;
28+
}
29+
30+
public createAcceptHeader(type: string, apiVersion?: string): string {
31+
return type + (apiVersion ? (';api-version=' + apiVersion) : '');
32+
}
33+
34+
public createRequestOptions(type: string, apiVersion?: string) {
35+
let options: rm.IRequestOptions = <rm.IRequestOptions>{};
36+
options.acceptHeader = this.createAcceptHeader(type, apiVersion);
37+
return options;
38+
}
39+
40+
public formatResponse(data: any, responseTypeMetadata: any, isCollection: boolean): any {
41+
let serializationData = {
42+
responseTypeMetadata: responseTypeMetadata,
43+
responseIsCollection: isCollection
44+
};
45+
let deserializedResult = serm.ContractSerializer.deserialize(data,
46+
serializationData.responseTypeMetadata,
47+
false,
48+
serializationData.responseIsCollection);
49+
return deserializedResult;
50+
}
51+
}

0 commit comments

Comments
 (0)