artifact-engine
Advanced tools
Comparing version 0.1.24 to 0.1.25
@@ -28,3 +28,3 @@ "use strict"; | ||
for (let i = 0; i < artifactEngineOptions.parallelProcessingLimit; ++i) { | ||
var worker = new worker_1.Worker(i + 1, item => this.processArtifactItem(sourceProvider, item, destProvider, artifactEngineOptions), () => this.artifactItemStore.getNextItemToProcess(), () => !this.artifactItemStore.itemsPendingProcessing()); | ||
var worker = new worker_1.Worker(i + 1, item => this.processArtifactItem(sourceProvider, item, destProvider, artifactEngineOptions), () => this.artifactItemStore.getNextItemToProcess(), () => !this.artifactItemStore.itemsPendingProcessing(), () => this.artifactItemStore.hasDownloadFailed()); | ||
workers.push(worker.init()); | ||
@@ -31,0 +31,0 @@ } |
@@ -45,3 +45,3 @@ "use strict"; | ||
+ ", Time elapsed: " + ((currentTime.valueOf() - this.startTime.valueOf()) / 1000) + "secs"); | ||
if (this.store.itemsPendingProcessing()) { | ||
if (this.store.itemsPendingProcessing() && !this.store.hasDownloadFailed()) { | ||
progressLogger(); | ||
@@ -48,0 +48,0 @@ } |
@@ -5,6 +5,7 @@ export declare class Worker<T> { | ||
private canExit; | ||
private hasDownloadFailed; | ||
private id; | ||
constructor(id: number, execute: (item: T) => Promise<void>, getNextItem: () => T, canExit: () => boolean); | ||
constructor(id: number, execute: (item: T) => Promise<void>, getNextItem: () => T, canExit: () => boolean, hasDownloadFailed: () => boolean); | ||
init(): Promise<void>; | ||
spawnWorker(resolve: any, reject: any): void; | ||
} |
"use strict"; | ||
const logger_1 = require('./logger'); | ||
class Worker { | ||
constructor(id, execute, getNextItem, canExit) { | ||
constructor(id, execute, getNextItem, canExit, hasDownloadFailed) { | ||
this.id = id; | ||
@@ -9,2 +9,3 @@ this.execute = execute; | ||
this.canExit = canExit; | ||
this.hasDownloadFailed = hasDownloadFailed; | ||
} | ||
@@ -19,2 +20,6 @@ init() { | ||
try { | ||
if (this.hasDownloadFailed()) { | ||
logger_1.Logger.logInfo(`Aborting respawning worker, as download failed for some file(s).`); | ||
return; | ||
} | ||
let item = this.getNextItem(); | ||
@@ -21,0 +26,0 @@ if (!item && !this.canExit()) { |
@@ -7,2 +7,3 @@ import { ItemType } from "./itemType"; | ||
lastModified: Date; | ||
contentType: string; | ||
metadata: { | ||
@@ -9,0 +10,0 @@ [key: string]: string; |
{ | ||
"name": "artifact-engine", | ||
"version": "0.1.24", | ||
"version": "0.1.25", | ||
"description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Microsoft/vsts-rm-extensions/tree/master/Extensions/ArtifactEngine" | ||
"url": "https://github.com/Microsoft/azure-pipelines-extensions/tree/master/Extensions/ArtifactEngine" | ||
}, | ||
@@ -9,0 +9,0 @@ "keywords": [ |
@@ -109,2 +109,3 @@ "use strict"; | ||
lastModified: itemStat.mtime, | ||
contentType: undefined, | ||
metadata: { "downloadUrl": filePath } | ||
@@ -111,0 +112,0 @@ }; |
@@ -14,3 +14,3 @@ import * as stream from 'stream'; | ||
dispose(): void; | ||
private getItems(itemsUrl); | ||
private getItems(itemsUrl, contentType); | ||
private getTemplateFilePath(); | ||
@@ -17,0 +17,0 @@ private extend(target, source); |
@@ -26,3 +26,4 @@ "use strict"; | ||
var itemsUrl = artifactItem.metadata["downloadUrl"]; | ||
return this.getItems(itemsUrl); | ||
var contentType = artifactItem.contentType; | ||
return this.getItems(itemsUrl, contentType); | ||
} | ||
@@ -35,5 +36,6 @@ getArtifactItem(artifactItem) { | ||
var downloadSize = 0; | ||
var contentType = artifactItem.contentType; | ||
var itemUrl = artifactItem.metadata['downloadUrl']; | ||
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.webClient.get(itemUrl).then((res) => { | ||
this.webClient.get(itemUrl, contentType ? { 'Accept': contentType } : undefined).then((res) => { | ||
res.message.on('data', (chunk) => { | ||
@@ -71,6 +73,6 @@ downloadSize += chunk.length; | ||
} | ||
getItems(itemsUrl) { | ||
getItems(itemsUrl, contentType) { | ||
var promise = new Promise((resolve, reject) => { | ||
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.webClient.get(itemsUrl, { 'Accept': 'application/json' }).then((res) => { | ||
this.webClient.get(itemsUrl, contentType ? { 'Accept': contentType } : { 'Accept': 'application/json' }).then((res) => { | ||
res.readBody().then((body) => { | ||
@@ -77,0 +79,0 @@ fs.readFile(this.getTemplateFilePath(), 'utf8', (err, templateFileContent) => { |
# Artifact Engine | ||
## Overview | ||
Artifact engine is a generic framework which supports download of artifacts from different providers like *jenkins, teamcity, vsts, bitbucket* e.t.c. The framework is extensible and other providers can be easily plugged in the downloader. | ||
Artifact engine is a generic framework which supports download of artifacts from different providers like *jenkins, teamcity, vsts, circleci, github-releases* e.t.c. The framework is extensible and other providers can be easily plugged in the downloader. | ||
## How to Use | ||
To use Artifact engine in your tasks or app have a look at [E2E.ts](E2ETests/E2E.ts). | ||
To use Artifact engine in your tasks or app have a look at [E2E.ts](E2ETests/jenkins.e2e.ts | ||
). | ||
## Usage | ||
![Daily downloads using artifact engine](https://github.com/Microsoft/azure-pipelines-extensions/blob/master/Extensions/ArtifactEngine/usage.png) | ||
## Architecture | ||
<img src="https://cdn.rawgit.com/omeshp/ItemLevelDownloader/f7a2d1a1/src/sequence.svg" height=600 width=800/> | ||
![Architecture](https://github.com/Microsoft/azure-pipelines-extensions/blob/master/Extensions/ArtifactEngine/sequence.svg) | ||
@@ -12,0 +16,0 @@ ## Development |
import * as models from "../Models"; | ||
export declare class ArtifactItemStore { | ||
_downloadTickets: models.ArtifactDownloadTicket[]; | ||
_hasDownloadFailed: boolean; | ||
addItem(item: models.ArtifactItem): void; | ||
@@ -16,2 +17,3 @@ addItems(items: models.ArtifactItem[]): void; | ||
flush(): void; | ||
hasDownloadFailed(): boolean; | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
this._downloadTickets = []; | ||
this._hasDownloadFailed = false; | ||
} | ||
@@ -51,2 +52,5 @@ addItem(item) { | ||
} | ||
if (state === models.TicketState.Failed) { | ||
this._hasDownloadFailed = true; | ||
} | ||
} | ||
@@ -85,5 +89,9 @@ } | ||
this._downloadTickets = []; | ||
this._hasDownloadFailed = false; | ||
} | ||
hasDownloadFailed() { | ||
return this._hasDownloadFailed; | ||
} | ||
} | ||
exports.ArtifactItemStore = ArtifactItemStore; | ||
//# sourceMappingURL=artifactItemStore.js.map |
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
40
148933
82
2019