How to use the artifact-engine/Providers/typed-rest-client/Handlers.BasicCredentialHandler 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 / JenkinsDownloadArtifactsV1 / jenkinsdownloadartifacts.ts View on Github external
}
        else {
            jenkinsJobDetails = await jenkinsClient.GetJobDetails();
            console.log(tl.loc("FoundJenkinsJobDetails", jenkinsJobDetails.jobName, jenkinsJobDetails.jobType, jenkinsJobDetails.buildId, jenkinsJobDetails.multiBranchPipelineName));

            const artifactQueryUrl: string = `${serverEndpointUrl}/${jenkinsJobDetails.jobUrlInfix}/${jenkinsJobDetails.multiBranchPipelineUrlInfix}/${jenkinsJobDetails.buildId}/api/json?tree=artifacts[*]`;
            var variables = {
                "endpoint": {
                    "url": serverEndpointUrl
                },
                "jobUrlInfix": jenkinsJobDetails.jobUrlInfix,
                "multibranchPipelineUrlInfix": jenkinsJobDetails.multiBranchPipelineUrlInfix,
                "version": jenkinsJobDetails.buildId
            };

            var handler = new handlers.BasicCredentialHandler(username, password);
            var hasArtifacts = await jenkinsClient.HasAssociatedArtifacts(artifactQueryUrl);

            if (hasArtifacts) {
                if (!itemPattern || itemPattern === '**') {
                    const archiveUrl: string = `${serverEndpointUrl}/${jenkinsJobDetails.jobUrlInfix}/${jenkinsJobDetails.multiBranchPipelineUrlInfix}/${jenkinsJobDetails.buildId}/artifact/*zip*/`
                    var zipLocation = path.join(localPathRoot, "archive.zip");
                    await getZipFromUrl(archiveUrl, strictSSL, zipLocation, handler);

                    var unzipPromise = unzip(zipLocation, localPathRoot);
                    unzipPromise.catch((error) => {
                        throw error;
                    });

                    await unzipPromise;

                    if (tl.exist(zipLocation)) {
github microsoft / azure-pipelines-tasks / Tasks / CircleCIDownloadArtifactsV0 / download.ts View on Github external
let itemPattern = tl.getInput("itemPattern", false);
        let downloadPath = tl.getInput("downloadPath", true);

        var endpointUrl = tl.getEndpointUrl(connection, false);
        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));
github microsoft / azure-pipelines-tasks / Tasks / JenkinsDownloadArtifactsV1 / ArtifactDetails / JenkinsRestClient.ts View on Github external
const endpoint = tl.getInput("serverEndpoint", true);
        const strictSSL: boolean = ('true' !== tl.getEndpointDataParameter(endpoint, 'acceptUntrustedCerts', true));

        let requestOptions: IHttpRequestOptions = {
            ignoreSslError: !strictSSL
        };

        let proxyUrl: string = tl.getVariable("agent.proxyurl");
        if (!!proxyUrl) {
            requestOptions.proxy = tl.getHttpProxyConfiguration();
        }

        const username = tl.getEndpointAuthorizationParameter(endpoint, 'username', false);
        const password = tl.getEndpointAuthorizationParameter(endpoint, 'password', false);
        var handler = new handlers.BasicCredentialHandler(username, password);

        return new HttpClient("JenkinsRestClient", [handler], requestOptions);
    }