How to use the artifact-engine/Providers.FilesystemProvider 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 / DownloadBuildArtifactsV0 / main.ts View on Github external
var containerId = parseInt(containerParts[1]);
                        var containerPath = containerParts.slice(2, containerParts.length).join('/');

                        if (containerPath == "/") {
                            //container REST api oddity. Passing '/' as itemPath downloads the first file instead of returning the meta data about the all the files in the root level. 
                            //This happens only if the first item is a file.
                            containerPath = ""
                        }

                        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;
                    }
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 / DownloadFileshareArtifactsV0 / main.ts View on Github external
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) => {
            reject(error);
        });
    });
github microsoft / azure-pipelines-tasks / Tasks / DownloadBuildArtifactsV0 / main.ts View on Github external
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);
                    }));
                }
                else {
                    console.log(tl.loc("UnsupportedArtifactType", artifact.resource.type));
                }
            });
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 / 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)
}