artifact-engine
Advanced tools
Comparing version 0.1.22 to 0.1.23
@@ -60,3 +60,2 @@ "use strict"; | ||
if (retryCount === artifactEngineOptions.retryLimit - 1) { | ||
logger_1.Logger.logError(err); | ||
this.artifactItemStore.updateState(item, models.TicketState.Failed); | ||
@@ -66,3 +65,2 @@ reject(err); | ||
else { | ||
logger_1.Logger.logMessage(err); | ||
this.artifactItemStore.increaseRetryCount(item); | ||
@@ -99,6 +97,8 @@ logger_1.Logger.logMessage(tl.loc("RetryingDownload", item.path, (retryCount + 1))); | ||
}, (err) => { | ||
retryIfRequired("Error placing file " + item.path + ": " + err); | ||
logger_1.Logger.logInfo("Error placing file " + item.path + ": " + err); | ||
retryIfRequired(err); | ||
}); | ||
}, (err) => { | ||
retryIfRequired("Error getting file " + item.path + ": " + err); | ||
logger_1.Logger.logInfo("Error getting file " + item.path + ": " + err); | ||
retryIfRequired(err); | ||
}); | ||
@@ -125,3 +125,4 @@ } | ||
}, (err) => { | ||
retryIfRequired("Error getting " + item.path + ":" + err); | ||
logger_1.Logger.logInfo("Error getting " + item.path + ":" + err); | ||
retryIfRequired(err); | ||
}); | ||
@@ -128,0 +129,0 @@ } |
@@ -11,4 +11,5 @@ { | ||
"UnhandledRejection": "artifact-engine: unhandled rejection %s", | ||
"UnhandledException": "artifact-engine: unhandled exception %s" | ||
"UnhandledException": "artifact-engine: unhandled exception %s", | ||
"FailedRequest": "Failed request: (statusCode)" | ||
} | ||
} |
{ | ||
"name": "artifact-engine", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts", | ||
@@ -5,0 +5,0 @@ "repository": { |
"use strict"; | ||
const fs = require('fs'); | ||
const crypto = require('crypto'); | ||
const httpm = require('./typed-rest-client/HttpClient'); | ||
var packagejson = require('../package.json'); | ||
const webClient_1 = require('./webClient'); | ||
class WebClientFactory { | ||
@@ -11,3 +10,3 @@ static getClient(handlers, options) { | ||
this.initializeProxy(options); | ||
return new httpm.HttpClient('artifact-engine ' + packagejson.version, handlers, options); | ||
return new webClient_1.WebClient(handlers, options); | ||
} | ||
@@ -14,0 +13,0 @@ static initializeProxy(options) { |
import * as stream from 'stream'; | ||
import * as httpm from './typed-rest-client/HttpClient'; | ||
import * as models from '../Models'; | ||
import { ArtifactItem, IArtifactProvider } from '../Models'; | ||
import { ArtifactItemStore } from '../Store/artifactItemStore'; | ||
import { WebClient } from './webClient'; | ||
import { IRequestHandler, IRequestOptions } from './typed-rest-client/Interfaces'; | ||
import { ArtifactItemStore } from '../Store/artifactItemStore'; | ||
export declare class WebProvider implements models.IArtifactProvider { | ||
export declare class WebProvider implements IArtifactProvider { | ||
artifactItemStore: ArtifactItemStore; | ||
constructor(rootItemsLocation: any, templateFile: string, variables: any, handler: IRequestHandler, requestOptions?: IRequestOptions); | ||
getRootItems(): Promise<models.ArtifactItem[]>; | ||
getArtifactItems(artifactItem: models.ArtifactItem): Promise<models.ArtifactItem[]>; | ||
getArtifactItem(artifactItem: models.ArtifactItem): Promise<NodeJS.ReadableStream>; | ||
putArtifactItem(item: models.ArtifactItem, readStream: stream.Readable): Promise<models.ArtifactItem>; | ||
getRootItems(): Promise<ArtifactItem[]>; | ||
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>; | ||
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>; | ||
putArtifactItem(item: ArtifactItem, readStream: stream.Readable): Promise<ArtifactItem>; | ||
dispose(): void; | ||
@@ -20,3 +20,3 @@ private getItems(itemsUrl); | ||
private variables; | ||
httpc: httpm.HttpClient; | ||
webClient: WebClient; | ||
} |
@@ -5,6 +5,5 @@ "use strict"; | ||
const zlib = require('zlib'); | ||
const httpm = require('./typed-rest-client/HttpClient'); | ||
const models = require('../Models'); | ||
const Models_1 = require('../Models'); | ||
const logger_1 = require('../Engine/logger'); | ||
const factory = require('./webClientFactory'); | ||
const webClientFactory_1 = require('./webClientFactory'); | ||
var handlebars = require('handlebars'); | ||
@@ -14,13 +13,12 @@ var tl = require('vsts-task-lib/task'); | ||
constructor(rootItemsLocation, templateFile, variables, handler, requestOptions) { | ||
this.httpc = new httpm.HttpClient('artifact-engine'); | ||
this.rootItemsLocation = rootItemsLocation; | ||
this.templateFile = templateFile; | ||
this.httpc = factory.WebClientFactory.getClient([handler], requestOptions); | ||
this.webClient = webClientFactory_1.WebClientFactory.getClient([handler], requestOptions); | ||
this.variables = variables; | ||
} | ||
getRootItems() { | ||
var rootItem = new models.ArtifactItem(); | ||
var rootItem = new Models_1.ArtifactItem(); | ||
rootItem.metadata = { downloadUrl: this.rootItemsLocation }; | ||
rootItem.path = ''; | ||
rootItem.itemType = models.ItemType.Folder; | ||
rootItem.itemType = Models_1.ItemType.Folder; | ||
return Promise.resolve([rootItem]); | ||
@@ -40,3 +38,3 @@ } | ||
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.httpc.get(itemUrl).then((res) => { | ||
this.webClient.get(itemUrl).then((res) => { | ||
res.message.on('data', (chunk) => { | ||
@@ -72,3 +70,3 @@ downloadSize += chunk.length; | ||
dispose() { | ||
this.httpc.dispose(); | ||
this.webClient.dispose(); | ||
} | ||
@@ -78,4 +76,4 @@ getItems(itemsUrl) { | ||
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.httpc.get(itemsUrl, { 'Accept': 'application/json' }).then((resp) => { | ||
resp.readBody().then((body) => { | ||
this.webClient.get(itemsUrl, { 'Accept': 'application/json' }).then((res) => { | ||
res.readBody().then((body) => { | ||
fs.readFile(this.getTemplateFilePath(), 'utf8', (err, templateFileContent) => { | ||
@@ -82,0 +80,0 @@ if (err) { |
import { ArtifactItemStore } from '../Store/artifactItemStore'; | ||
import { ArtifactItem, IArtifactProvider } from '../Models'; | ||
import { WebClient } from './webClient'; | ||
import { IRequestHandler, IRequestOptions } from './typed-rest-client/Interfaces'; | ||
import * as httpm from './typed-rest-client/HttpClient'; | ||
import * as models from '../Models'; | ||
export declare class ZipProvider implements models.IArtifactProvider { | ||
export declare class ZipProvider implements IArtifactProvider { | ||
artifactItemStore: ArtifactItemStore; | ||
constructor(zipLocation: any, handler: IRequestHandler, requestOptions?: IRequestOptions); | ||
getRootItems(): Promise<models.ArtifactItem[]>; | ||
getArtifactItems(artifactItem: models.ArtifactItem): Promise<models.ArtifactItem[]>; | ||
getArtifactItem(artifactItem: models.ArtifactItem): Promise<NodeJS.ReadableStream>; | ||
putArtifactItem(artifactItem: models.ArtifactItem, stream: NodeJS.ReadableStream): Promise<models.ArtifactItem>; | ||
getRootItems(): Promise<ArtifactItem[]>; | ||
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>; | ||
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>; | ||
putArtifactItem(artifactItem: ArtifactItem, stream: NodeJS.ReadableStream): Promise<ArtifactItem>; | ||
dispose(): void; | ||
private zipLocation; | ||
httpc: httpm.HttpClient; | ||
webClient: WebClient; | ||
} |
"use strict"; | ||
const httpm = require('./typed-rest-client/HttpClient'); | ||
const models = require('../Models'); | ||
const Models_1 = require('../Models'); | ||
const factory = require('./webClientFactory'); | ||
class ZipProvider { | ||
constructor(zipLocation, handler, requestOptions) { | ||
this.httpc = new httpm.HttpClient('artifact-engine'); | ||
this.zipLocation = zipLocation; | ||
this.httpc = factory.WebClientFactory.getClient([handler], requestOptions); | ||
this.webClient = factory.WebClientFactory.getClient([handler], requestOptions); | ||
} | ||
getRootItems() { | ||
var rootItem = new models.ArtifactItem(); | ||
var rootItem = new Models_1.ArtifactItem(); | ||
rootItem.metadata = { downloadUrl: this.zipLocation }; | ||
rootItem.path = ''; | ||
rootItem.itemType = models.ItemType.File; | ||
rootItem.itemType = Models_1.ItemType.File; | ||
return Promise.resolve([rootItem]); | ||
@@ -29,3 +27,3 @@ } | ||
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.httpc.get(itemUrl).then((res) => { | ||
this.webClient.get(itemUrl).then((res) => { | ||
resolve(res.message); | ||
@@ -32,0 +30,0 @@ }, (reason) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
160945
83
2287