How to use the artifact-engine/Engine.ArtifactEngine function in artifact-engine

To help you get started, we’ve selected a few artifact-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-tasks / Tasks / DownloadBuildArtifacts / main.ts View on Github external
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];

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

                    var variables = {};
                    var handler = new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
                    var webProvider = new providers.WebProvider(itemsUrl, templatePath, variables, handler);
                    var fileSystemProvider = new providers.FilesystemProvider(downloadPath);
github microsoft / azure-pipelines-tasks / Tasks / JenkinsDownloadArtifactsV1 / jenkinsdownloadartifacts.ts View on Github external
async function getArtifactsFromUrl(artifactQueryUrl: string, strictSSL: boolean, localPathRoot: string, itemPattern: string, handler: handlers.BasicCredentialHandler, variables: { [key: string]: any }) {
    console.log(tl.loc('ArtifactDownloadUrl', artifactQueryUrl));

    var templatePath = path.join(__dirname, 'jenkins.handlebars.txt');
    var webProvider = new providers.WebProvider(artifactQueryUrl, templatePath, variables, handler, { ignoreSslError: !strictSSL });
    var localFileProvider = new providers.FilesystemProvider(localPathRoot);

    var downloaderOptions = configureDownloaderOptions();
    var downloader = new engine.ArtifactEngine();
    await downloader.processItems(webProvider, localFileProvider, downloaderOptions);
}
github microsoft / azure-pipelines-tasks / Tasks / JenkinsDownloadArtifactsV1 / jenkinsdownloadartifacts.ts View on Github external
async function getZipFromUrl(artifactArchiveUrl: string, strictSSL: boolean, localPathRoot: string, handler: handlers.BasicCredentialHandler) {
    console.log(tl.loc('ArtifactDownloadUrl', artifactArchiveUrl));

    var downloaderOptions = configureDownloaderOptions();
    var downloader = new engine.ArtifactEngine();
    var zipProvider = new providers.ZipProvider(artifactArchiveUrl, handler, { ignoreSslError: !strictSSL });
    var filesystemProvider = new providers.FilesystemProvider(localPathRoot);

    await downloader.processItems(zipProvider, filesystemProvider, downloaderOptions)
}
github microsoft / azure-pipelines-tasks / Tasks / DownloadFileshareArtifactsV0 / main.ts View on Github external
const promise = new Promise(async (resolve, reject) => {
        const downloadPath: string = tl.getInput("downloadPath", true);
        const debugMode: string = tl.getVariable('System.Debug');
        const isVerbose: boolean = debugMode ? debugMode.toLowerCase() != 'false' : false;
        const parallelLimit: number = +tl.getInput("parallelizationLimit", false);
        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) {
github microsoft / azure-pipelines-tasks / Tasks / DownloadGitHubReleaseV0 / main.ts View on Github external
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
        
        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);
        });
    });
github microsoft / azure-pipelines-tasks / Tasks / CircleCIDownloadArtifactsV0 / download.ts View on Github external
var itemsUrl = `${endpointUrl}/api/v1.1/project/${definitionId}/${buildId}/artifacts`;
        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);
        });
github microsoft / azure-pipelines-tasks / Tasks / DownloadBuildArtifactsV0 / main.ts View on Github external
}

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

                        var variables = {};
                        var webProvider = new providers.WebProvider(itemsUrl, templatePath, variables, handler);
                        var fileSystemProvider = new providers.FilesystemProvider(downloadPath);

                        downloadPromises.push(downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
                            reject(reason);
                        }));
                    }
                }
                else if (artifact.resource.type.toLowerCase() === "filepath") {
                    let downloader = new engine.ArtifactEngine();
                    let downloadUrl = artifact.resource.data;
                    let artifactName = artifact.name.replace('/', '\\');
                    let artifactLocation = path.join(downloadUrl, artifactName);
                    if (!fs.existsSync(artifactLocation)) {
                        console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));
                        artifactLocation = downloadUrl;
                    }

                    console.log(tl.loc("DownloadArtifacts", artifact.name, artifactLocation));
                    var fileShareProvider = new providers.FilesystemProvider(artifactLocation, artifactName);
                    var fileSystemProvider = new providers.FilesystemProvider(downloadPath);

                    downloadPromises.push(downloader.processItems(fileShareProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
                        reject(reason);
                    }));
                }
github microsoft / azure-pipelines-tasks / Tasks / DownloadBuildArtifactsV0 / main.ts View on Github external
async function getZipFromUrl(artifactArchiveUrl: string, localPathRoot: string, handler: webHandlers.PersonalAccessTokenCredentialHandler, downloaderOptions: engine.ArtifactEngineOptions) {
    var downloader = new engine.ArtifactEngine();
    var zipProvider = new providers.ZipProvider(artifactArchiveUrl, handler);
    var filesystemProvider = new providers.FilesystemProvider(localPathRoot);

    await downloader.processItems(zipProvider, filesystemProvider, downloaderOptions)
}