• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Engine.ArtifactEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中artifact-engine/Engine.ArtifactEngine的典型用法代码示例。如果您正苦于以下问题:TypeScript ArtifactEngine类的具体用法?TypeScript ArtifactEngine怎么用?TypeScript ArtifactEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ArtifactEngine类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getZipFromUrl

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)
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:7,代码来源:main.ts


示例2: getZipFromUrl

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)
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:10,代码来源:jenkinsdownloadartifacts.ts


示例3: function

            artifacts.forEach(async function (artifact, index, artifacts) {
                let downloaderOptions = new engine.ArtifactEngineOptions();
                downloaderOptions.itemPattern = itemPattern;
                downloaderOptions.verbose = verbose;

                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";
                    itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
                    console.log(tl.loc("DownloadArtifacts", itemsUrl));

                    var variables = {};

                    var handler = username ? new webHandlers.BasicCredentialHandler(username, accessToken) : new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
                    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 artifactLocation = downloadUrl + '/' + artifact.name;
                    if (!fs.existsSync(artifactLocation)) {
                        console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));
                        artifactLocation = downloadUrl;
                    }

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

                    downloadPromises.push(downloader.processItems(fileShareProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
                        reject(reason);
                    }));
                }
                else {
                    console.log(tl.loc('UnsupportedArtifactType', artifact.resource.type));
                }
            });
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:54,代码来源:download.ts


示例4: getArtifactsFromUrl

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);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:jenkinsdownloadartifacts.ts


示例5: resolve

    var promise = new Promise<void>(async (resolve, reject) => {
        let connection = tl.getInput("connection", true);
        let definitionId = tl.getInput("definition", true);
        let buildId = tl.getInput("version", true);
        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));
            resolve();
        }).catch((error) => {
            reject(error);
        });
        
        let downloadCommitsFlag: boolean = tl.getBoolInput("downloadCommitsAndWorkItems", true);
        if (downloadCommitsFlag) {
            var webProviderForDownloaingCommits = new providers.WebProvider(itemsUrl, templatePath, circleciVariables, handler);
            downloadCommits(webProviderForDownloaingCommits);
        }
    });
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:47,代码来源:download.ts


示例6: resolve

    var promise = new Promise<void>(async (resolve, reject) => {
        let connection = tl.getInput("connection", true);
        let projectId = tl.getInput("project", true);
        let definitionId = tl.getInput("definition", true);
        let buildId = tl.getInput("version", true);
        let itemPattern = tl.getInput("itemPattern", false);
        let downloadPath = tl.getInput("downloadPath", true);

        var endpointUrl = tl.getEndpointUrl(connection, false);
        var itemsUrl = endpointUrl + "/httpAuth/app/rest/builds/id:" + buildId + "/artifacts/children/";
        itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
        console.log(tl.loc("DownloadArtifacts", itemsUrl));

        var templatePath = path.join(__dirname, 'teamcity.handlebars');
        var username = tl.getEndpointAuthorizationParameter(connection, 'username', false);
        var password = tl.getEndpointAuthorizationParameter(connection, 'password', false);
        var teamcityVariables = {
            "endpoint": {
                "url": endpointUrl
            }
        };
        var handler = new webHandlers.BasicCredentialHandler(username, password);
        var webProvider = new providers.WebProvider(itemsUrl, templatePath, teamcityVariables, handler);
        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;
        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);
        });
    });
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:44,代码来源:download.ts


示例7: parseInt

    const promise = new Promise<void>(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) {
            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);
        });
    });
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:40,代码来源:main.ts


示例8: function

            artifacts.forEach(async function (artifact, index, artifacts) {
                let downloaderOptions = configureDownloaderOptions();

                if (artifact.resource.type.toLowerCase() === "container") {
                    var handler = new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
                    var isPullRequestFork = tl.getVariable("SYSTEM.PULLREQUEST.ISFORK");
                    var isPullRequestForkBool = isPullRequestFork ? isPullRequestFork.toLowerCase() == 'true' : false;

                    if (isPullRequestForkBool) {
                        const archiveUrl: string =  endpointUrl + "/" + projectId + "/_apis/build/builds/" + buildId + "/artifacts?artifactName=" + artifact.name + "&$format=zip";
                        console.log(tl.loc("DownloadArtifacts", artifact.name, archiveUrl));

                        var zipLocation = path.join(downloadPath, artifact.name + ".zip");
                        await getZipFromUrl(archiveUrl, zipLocation, handler, downloaderOptions);

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

                        downloadPromises.push(unzipPromise);
                        await unzipPromise;

                        if (tl.exist(zipLocation)) {
                            tl.rmRF(zipLocation);
                        }
                    }
                    else {
                        let downloader = new engine.ArtifactEngine();

                        console.log(tl.loc("DownloadingContainerResource", artifact.resource.data));
                        var containerParts = artifact.resource.data.split('/');
    
                        if (containerParts.length < 3) {
                            throw new Error(tl.loc("FileContainerInvalidArtifactData"));
                        }
                        
                        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;
                    }

                    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));
                }
            });
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:80,代码来源:main.ts


示例9: function

            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();

                    console.log(tl.loc("DownloadingContainerResource", artifact.resource.data));
                    var containerParts = artifact.resource.data.split('/');

                    if (containerParts.length < 3) {
                        throw new Error(tl.loc("FileContainerInvalidArtifactData"));
                    }
                    
                    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 handler = new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
                    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);
                    }));
                }
                else {
                    console.log(tl.loc("UnsupportedArtifactType", artifact.resource.type));
                }
            });
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:62,代码来源:main.ts


示例10: parseInt

    var promise = new Promise<void>(async (resolve, reject) => {
        let connection = tl.getInput("connection", true);
        let repositoryName = tl.getInput("userRepository", true);
        let defaultVersionType = tl.getInput("defaultVersionType", true);
        let itemPattern = tl.getInput("itemPattern", false);
        let downloadPath = tl.getInput("downloadPath", true);
        let version = tl.getInput("version", false);
        let release: Release = null;

        if (!defaultVersionType) {
            defaultVersionType = "latest";
        }

        var token = tl.getEndpointAuthorizationParameter(connection, 'AccessToken', false);
        var retryLimit = parseInt(tl.getVariable("VSTS_HTTP_RETRY")) ? parseInt(tl.getVariable("VSTS_HTTP_RETRY")) : defaultRetryLimit;

        // Required to prevent typed-rest-client from adding additional 'Authorization' in header on redirect to AWS
        var customCredentialHandler = {
            canHandleAuthentication: () => false,
            handleAuthentication: () => { },
            prepareRequest: (options) => {
                if (options.host.indexOf("amazonaws") == -1) {
                    options.headers['Authorization'] = 'Bearer ' + token;
                }
                else {
                    if (!!options.headers['Authorization']) {
                        let updatedHeaders = {};
                        for (var key in options.headers) {
                            if (key.toLowerCase() != "authorization") {
                                updatedHeaders[key] = options.headers[key];
                            }
                        }

                        options.headers = updatedHeaders;
                    }
                }
            }
        }

        if (defaultVersionType.toLowerCase() == 'specificversion') {
            release = await executeWithRetries("getSpecificRelease", () => getSpecificRelease(repositoryName, version, customCredentialHandler), retryLimit).catch((reason) => { reject(reason); });
        }
        else if (defaultVersionType.toLowerCase() == 'specifictag') {
            release = await executeWithRetries("getTaggedRelease", () => getTaggedRelease(repositoryName, version, customCredentialHandler), retryLimit).catch((reason) => { reject(reason); });
        }
        else {
            if (!!version) {
                release = await executeWithRetries("getTaggedRelease", () => getTaggedRelease(repositoryName, version, customCredentialHandler), retryLimit).catch((reason) => { reject(reason); });
            }
            else {
                release = await executeWithRetries("getLatestRelease", () => getLatestRelease(repositoryName, customCredentialHandler), retryLimit).catch((reason) => { reject(reason); });
            }
        }

        if (!release || !release.Id) {
            reject(tl.loc("InvalidRelease", version));
            return;
        }

        var itemsUrl = "https://api.github.com/repos/" + repositoryName + "/releases/" + release.Id + "/assets";
        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);
        });
    });
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:92,代码来源:main.ts



注:本文中的artifact-engine/Engine.ArtifactEngine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Verify.that函数代码示例发布时间:2022-05-25
下一篇:
TypeScript article.IViewArticle类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap