Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
console.log(tl.loc("DownloadArtifacts", itemsUrl));
var templatePath = path.join(__dirname, 'circleCI.handlebars.txt');
var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
var circleciVariables = {
"endpoint": {
"url": endpointUrl
}
};
var handler = new webHandlers.BasicCredentialHandler(username, "");
var webProvider = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
var downloader = new engine.ArtifactEngine();
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
var parallelLimit : number = +tl.getVariable("release.artifact.download.parallellimit");
if(parallelLimit){
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
reject(error);
});
console.log(tl.loc("DownloadArtifacts", release.Name, itemsUrl));
var templatePath = path.join(__dirname, 'githubrelease.handlebars.txt');
var gitHubReleaseVariables = {
"endpoint": {
"url": "https://api.github.com/"
}
};
var webProvider = new providers.WebProvider(itemsUrl, templatePath, gitHubReleaseVariables, customCredentialHandler);
var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
var parallelLimit: number = +tl.getVariable("release.artifact.download.parallellimit");
var downloader = new engine.ArtifactEngine();
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern ? itemPattern : '**';
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
if (parallelLimit) {
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
await downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).then((result) => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
reject(error);
});
});
const retryLimit = parseInt(tl.getVariable("VSTS_HTTP_RETRY")) ? parseInt(tl.getVariable("VSTS_HTTP_RETRY")) : 4;
const itemPattern: string = tl.getInput("itemPattern", false) || '**';
const downloader = new engine.ArtifactEngine();
const downloadUrl = tl.getInput("filesharePath", true);
let artifactName = tl.getInput("artifactName", true);
artifactName = artifactName.replace('/', '\\');
let artifactLocation = path.join(downloadUrl, artifactName);
console.log(tl.loc("DownloadArtifacts", artifactName, artifactLocation));
if (!fs.existsSync(artifactLocation)) {
console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));
artifactLocation = downloadUrl;
}
let downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern;
downloaderOptions.verbose = isVerbose;
if (parallelLimit) {
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
let fileShareProvider = new providers.FilesystemProvider(artifactLocation, artifactName);
let fileSystemProvider = new providers.FilesystemProvider(downloadPath);
let downloadPromise = downloader.processItems(fileShareProvider, fileSystemProvider, downloaderOptions);
downloadPromise.then(() => {
console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
resolve();
}).catch((error) => {
artifacts.forEach(async function (artifact, index, artifacts) {
let downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = itemPattern;
downloaderOptions.verbose = isVerbose;
if (parallelLimit) {
downloaderOptions.parallelProcessingLimit = parallelLimit;
}
if (artifact.resource.type.toLowerCase() === "container") {
let downloader = new engine.ArtifactEngine();
var containerParts: string[] = artifact.resource.data.split('/', 3);
if (containerParts.length !== 3) {
throw new Error(tl.loc("FileContainerInvalidArtifactData"));
}
var containerId: number = parseInt(containerParts[1]);
var containerPath: string = containerParts[2];
function configureDownloaderOptions(): engine.ArtifactEngineOptions {
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = tl.getInput('itemPattern', false) || "**";
downloaderOptions.parallelProcessingLimit = +tl.getVariable("release.artifact.download.parallellimit") || 4;
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
return downloaderOptions;
}
function configureDownloaderOptions(): engine.ArtifactEngineOptions {
var downloaderOptions = new engine.ArtifactEngineOptions();
downloaderOptions.itemPattern = tl.getInput('itemPattern', false) || "**";
downloaderOptions.parallelProcessingLimit = +tl.getVariable("release.artifact.download.parallellimit") || 8;
var debugMode = tl.getVariable('System.Debug');
downloaderOptions.verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
return downloaderOptions;
}