当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript task.assertAgent函数代码示例

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


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

示例1: publishEvent

export function publishEvent(properties: { [key: string]: any }): void {
    try {
        tl.assertAgent('2.125.0');
        tl.publishTelemetry(area, feature, Object.assign(getDefaultProps(), properties));

    } catch (err) {
        tl.debug('Unable to publish telemetry due to lower agent version.');
    }
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:9,代码来源:cieventlogger.ts

示例2: getTempFolder

export function getTempFolder(): string {
    try {
        tl.assertAgent('2.115.0');
        const tmpDir =  tl.getVariable('Agent.TempDirectory');
        return tmpDir;
    } catch (err) {
        tl.warning(tl.loc('UpgradeAgentMessage'));
        return os.tmpdir();
    }
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:10,代码来源:helpers.ts

示例3: prependPathSafe

export function prependPathSafe(toolPath: string) {
    task.assertAgent('2.115.0');

    console.log(task.loc('PrependPath', toolPath));
    const newPath: string = toolPath + path.delimiter + process.env['PATH'];
    task.debug('new Path: ' + newPath);
    process.env['PATH'] = newPath;

    // instruct the agent to set this path on future tasks
    console.log('##vso[task.prependpath]' + toolPath);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:11,代码来源:toolutil.ts

示例4: acquireNode

async function acquireNode(version: string): Promise<string> {
    //
    // Download - a tool installer intimately knows how to get the tool (and construct urls)
    //
    version = toolLib.cleanVersion(version);
    let fileName: string = osPlat == 'win32'? 'node-v' + version + '-win-' + os.arch() :
                                                'node-v' + version + '-' + osPlat + '-' + os.arch();  
    let urlFileName: string = osPlat == 'win32'? fileName + '.7z':
                                                    fileName + '.tar.gz';  

    let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;

    let downloadPath: string;

    try 
    {
        downloadPath = await toolLib.downloadTool(downloadUrl);
    } 
    catch (err)
    {
        if (err['httpStatusCode'] && 
            err['httpStatusCode'] == '404')
        {
            return await acquireNodeFromFallbackLocation(version);
        }

        throw err;
    }
    
    //
    // Extract
    //
    let extPath: string;
    if (osPlat == 'win32') {
        taskLib.assertAgent('2.115.0');
        extPath = taskLib.getVariable('Agent.TempDirectory');
        if (!extPath) {
            throw new Error('Expected Agent.TempDirectory to be set');
        }

        extPath = path.join(extPath, 'n'); // use as short a path as possible due to nested node_modules folders
        extPath = await toolLib.extract7z(downloadPath, extPath);
    }
    else {
        extPath = await toolLib.extractTar(downloadPath);
    }

    //
    // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
    //
    let toolRoot = path.join(extPath, fileName);
    return await toolLib.cacheDir(toolRoot, 'node', version);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:53,代码来源:nodetool.ts

示例5: acquireGo

async function acquireGo(version: string): Promise<string> {
    //
    // Download - a tool installer intimately knows how to get the tool (and construct urls)
    //
    let fileName: string = getFileName(version);
    let downloadUrl: string = getDownloadUrl(fileName);
    let downloadPath: string = null;
    try {
        downloadPath = await toolLib.downloadTool(downloadUrl);
    } catch (error) {
        tl.debug(error);

        // cannot localized the string here because to localize we need to set the resource file.
        // which can be set only once. vsts-task-tool-lib/tool, is already setting it to different file.
        // So left with no option but to hardcode the string. Other tasks are doing the same.
        throw (util.format("Failed to download version %s. Please verify that the version is valid and resolve any other issues. %s", version, error));
    }

    //make sure agent version is latest then 2.115.0
    tl.assertAgent('2.115.0');

    //
    // Extract
    //
    let extPath: string;
    extPath = tl.getVariable('Agent.TempDirectory');
    if (!extPath) {
        throw new Error("Expected Agent.TempDirectory to be set");
    }

    if (osPlat == 'win32') {
        extPath = await toolLib.extractZip(downloadPath);
    }
    else {
        extPath = await toolLib.extractTar(downloadPath);
    }

    //
    // Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
    //
    let toolRoot = path.join(extPath, "go");
    version = fixVersion(version);
    return await toolLib.cacheDir(toolRoot, 'go', version);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:44,代码来源:gotool.ts


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