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


TypeScript task.setVariable函数代码示例

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


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

示例1: run

async function run() {
    let packageType = tl.getInput('packageType', true).toLowerCase();
    let versionSpec = tl.getInput('version', true);
    let installationPath = tl.getInput('installationPath', false);
    if (!installationPath) {
        installationPath = path.join(tl.getVariable('Agent.ToolsDirectory'), "dotnet");
    }
    let includePreviewVersions: boolean = tl.getBoolInput('includePreviewVersions', false) || false;

    console.log(tl.loc("ToolToInstall", packageType, versionSpec));
    var versionSpecParts = new VersionParts(versionSpec);

    let versionFetcher = new DotNetCoreVersionFetcher();
    let versionInfo: VersionInfo = await versionFetcher.getVersionInfo(versionSpecParts.versionSpec, packageType, includePreviewVersions);
    if (!versionInfo) {
        throw tl.loc("MatchingVersionNotFound", versionSpecParts.versionSpec);
    }

    let dotNetCoreInstaller = new VersionInstaller(packageType, installationPath);
    if (!dotNetCoreInstaller.isVersionInstalled(versionInfo.getVersion())) {
        await dotNetCoreInstaller.downloadAndInstall(versionInfo, versionFetcher.getDownloadUrl(versionInfo));
    }

    toolLib.prependPath(installationPath);

    // By default disable Multi Level Lookup unless user wants it enabled.
    let  performMultiLevelLookup = tl.getBoolInput("performMultiLevelLookup", false);
    tl.setVariable("DOTNET_MULTILEVEL_LOOKUP", !performMultiLevelLookup ? "0" : "1");

    // Add dot net tools path to "PATH" environment variables, so that tools can be used directly.
    addDotNetCoreToolPath();

    // Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
    tl.setVariable('DOTNET_ROOT', installationPath);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:35,代码来源:dotnetcoreinstaller.ts

示例2: activateEnvironment

export function activateEnvironment(environmentsDir: string, environmentName: string, platform: Platform): void {
    const environmentPath = path.join(environmentsDir, environmentName);
    prependCondaToPath(environmentPath, platform);

    // If Conda ever changes the names of the environment variables it uses to find its environment, this task will break.
    // For now we will assume these names are stable.
    // If we ever get broken, we should write code to run the activation script, diff the environment before and after,
    // and surface up the new environment variables as build variables.
    task.setVariable('CONDA_DEFAULT_ENV', environmentName);
    task.setVariable('CONDA_PREFIX', environmentPath);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:conda_internal.ts

示例3: setOutputVariables

function setOutputVariables(packerHost: packerHost, outputs: Map<string, string>): void {
    var taskParameters = packerHost.getTaskParameters();
    var imageUri;
    var imageId;
    var managedImageName;
      
    if (!utils.IsNullOrEmpty(taskParameters.imageId) && !(taskParameters.templateType == constants.TemplateTypeBuiltin && !taskParameters.isManagedImage)) {
        imageId = getValueFromOutputs(constants.PackerLogTokenManagedImageId, outputs);

        if (!utils.IsNullOrEmpty(imageId)) {
            tl.debug("Setting image Id variable which contains the managed image Id to: " + imageId);
            tl.setVariable(taskParameters.imageId, imageId);
        } else {
            throw tl.loc("ImageIDOutputVariableNotFound");
        }
    }

    if (!utils.IsNullOrEmpty(taskParameters.imageUri)) {
        if (taskParameters.templateType === constants.TemplateTypeBuiltin) {
            if (!taskParameters.isManagedImage) {
                imageUri = getValueFromOutputs(constants.PackerLogTokenImageUri, outputs);
                if (!utils.IsNullOrEmpty(imageUri)) {
                    tl.debug("Setting image URI variable to: " + imageUri);
                    tl.setVariable(taskParameters.imageUri, imageUri);
                } else {
                    throw tl.loc("ImageURIOutputVariableNotFound");
                }
            } else {
                imageUri = getValueFromOutputs(constants.PackerLogTokenManagedImageName, outputs);
                if (!utils.IsNullOrEmpty(imageUri)) {
                    tl.debug("Setting image URI variable which contains the managed image name to: " + imageUri);
                    tl.setVariable(taskParameters.imageUri, imageUri);
                } else {
                    throw tl.loc("ManagedImageNameOutputVariableNotFound");
                }
            }
        } else {
            imageUri = getValueFromOutputs(constants.PackerLogTokenImageUri, outputs);
            managedImageName = getValueFromOutputs(constants.PackerLogTokenManagedImageName, outputs);

            if (!utils.IsNullOrEmpty(managedImageName)) {
                tl.debug("Setting image URI variable which contains the managed image name to: " + managedImageName);
                tl.setVariable(taskParameters.imageUri, managedImageName);
            }
            else if (!utils.IsNullOrEmpty(imageUri)) {
                tl.debug("Setting image URI variable to: " + imageUri);
                tl.setVariable(taskParameters.imageUri, imageUri);
            }
            else {
                throw tl.loc("CustumTemplateOutputVariableNotFound");
            }
        }
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:54,代码来源:packerBuild.ts

示例4: saveMachineGroup

export function saveMachineGroup(machineGroup: MachineGroup): void {
    if (machineGroup == null) {
        throwAndLog("Invalid machine group");
    }
    if (machineGroup.Name == null || machineGroup.Name.trim() == "") {
        throwAndLog("Invalid machine group name");
    }

    var machineGroupOutputVariableName = machineGroupOutputVariablePrefix + machineGroup.Name;
    tl.setVariable(machineGroupOutputVariableName, JSON.stringify(machineGroup));
    tl.setVariable(machineGroup.Name, machineGroupOutputVariableName);
    tl.debug("Saved machine group with name '" + machineGroup.Name + "'");
}
开发者ID:nphmuller,项目名称:vsts-vmware,代码行数:13,代码来源:deployment.ts

示例5: setGoEnvironmentVariables

function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    let goPath: string = tl.getInput("goPath", false);
    let goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:14,代码来源:gotool.ts

示例6: useRubyVersion

export async function useRubyVersion(parameters: TaskParameters, platform: Platform): Promise<void> {
    const toolName: string = 'Ruby';
    const installDir: string | null = tool.findLocalTool(toolName, parameters.versionSpec);
    if (!installDir) {
        // Fail and list available versions
        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            tool.findLocalToolVersions('Ruby'),
            task.loc('ToolNotFoundMicrosoftHosted', 'Ruby', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Ruby', 'https://go.microsoft.com/fwlink/?linkid=2005989')
        ].join(os.EOL));
    }

    const toolPath: string = path.join(installDir, 'bin');
    if (platform !== Platform.Windows) {
        // Ruby / Gem heavily use the '#!/usr/bin/ruby' to find ruby, so this task needs to
        // replace that version of ruby so all the correct version of ruby gets selected
        // replace the default
        const dest: string = '/usr/bin/ruby';
        task.execSync('sudo', `ln -sf ${path.join(toolPath, 'ruby')} ${dest}`); // replace any existing
    }

    task.setVariable('rubyLocation', toolPath);
    if (parameters.addToPath) {
        tool.prependPath(toolPath);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:28,代码来源:userubyversion.ts

示例7: unsetDockerConfigEnvVariable

 public unsetDockerConfigEnvVariable() {
     var dockerConfigPath = tl.getVariable("DOCKER_CONFIG");
     if (dockerConfigPath) {
         tl.setVariable("DOCKER_CONFIG", "");
         del.sync(dockerConfigPath, {force: true});
     }    
 }
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:7,代码来源:containerconnection.ts

示例8: useRubyVersion

export async function useRubyVersion(parameters: TaskParameters, platform: Platform): Promise<void> {
    const toolName: string = 'Ruby';
    const installDir: string | null = tool.findLocalTool(toolName, parameters.versionSpec);
    if (!installDir) {
        // Fail and list available versions
        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec),
            task.loc('ListAvailableVersions'),
            tool.findLocalToolVersions('Ruby')
        ].join(os.EOL));
    }

    const toolPath: string = path.join(installDir, 'bin');
    if (platform !== Platform.Windows) {
        // replace the default
        const dest: string = '/usr/bin/ruby';
        if (fs.existsSync(dest)) {
            task.debug('removing ' + dest);
            fs.unlinkSync(dest);
        }
        fs.symlinkSync(path.join(toolPath, 'ruby'), dest);
    }

    task.setVariable('rubyLocation', toolPath);
    if (parameters.addToPath) {
        tool.prependPath(toolPath);
    }
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:28,代码来源:userubyversion.ts

示例9: setKubeConfigEnvVariable

 public setKubeConfigEnvVariable() {
     if (this.kubeconfigFile && fs.existsSync(this.kubeconfigFile)) {
         tl.setVariable("KUBECONFIG", this.kubeconfigFile);
     }
     else {
         tl.error(tl.loc('KubernetesServiceConnectionNotFound'));
         throw new Error(tl.loc('KubernetesServiceConnectionNotFound'));
     }
 }
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:9,代码来源:clusterconnection.ts

示例10: setDockerConfigEnvVariable

 public setDockerConfigEnvVariable() {
     if (this.configurationDirPath && fs.existsSync(this.configurationDirPath)) {
         tl.setVariable("DOCKER_CONFIG", this.configurationDirPath, true);
     }
     else {
         tl.error(tl.loc('DockerRegistryNotFound'));
         throw new Error(tl.loc('DockerRegistryNotFound'));
     }
 }
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:9,代码来源:containerconnection.ts


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