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

TypeScript task.setVariable函数代码示例

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

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



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

示例1: getAdvinst

async function getAdvinst(version: string, license: string): Promise<void> {

  if (!semvish.valid(version))
    throw Error(taskLib.loc("AI_InvalidVersionFormat", version));

  let cachedToolRoot: string;
  //Verify if this version of advinst was already installed.
  cachedToolRoot = _getLocalTool(semvish.clean(version));

  if (!cachedToolRoot) {
    console.log(taskLib.loc("AI_InstallNewTool"));
    //Extract advinst.msi and cache the content.
    cachedToolRoot = await acquireAdvinst(version);
  }
  else {
    console.log(taskLib.loc("AI_UseCachedTool", cachedToolRoot));
  }

  let msBuildTargetsPath: string = path.join(cachedToolRoot, advinstMSBuildTargetsSubPath);
  //Compute the actual AdvancedInstaller.com folder
  let advinstBinRoot: string = path.join(cachedToolRoot, advinstToolSubPath);
  //Debug traces
  taskLib.debug('cachedToolRoot = ' + cachedToolRoot);
  taskLib.debug('advinstBinRoot = ' + advinstBinRoot);
  taskLib.debug('msBuildTargetsPath = ' + msBuildTargetsPath);

  //Register advinst if a license key was provided
  await registerAdvinst(advinstBinRoot, license);
  //Add the advinst folder to PATH
  toolLib.prependPath(advinstBinRoot);

  //Set the environment variables that will be used by Advanced Installer tasks later on.
  taskLib.setVariable(advinstMSBuildTargetsVar, msBuildTargetsPath);
  taskLib.setVariable(advinstToolRootVar, cachedToolRoot);
}
开发者ID:Caphyon,项目名称:advinst-vsts-task,代码行数:35,代码来源:AdvinstTool.ts


示例2: run

export async function run() {
  let templateFilePath: string = tl.getPathInput("templateFilePath", true);
  tl.debug(`The template file path is ${templateFilePath}`);
  if (!fs.existsSync(templateFilePath)) {
    throw Error(tl.loc('TemplateFileInvalid', templateFilePath));
  }
  util.setTaskRootPath(path.dirname(templateFilePath));

  util.setupIotedgedev();

  let envList = {
    [Constants.iotedgedevEnv.deploymentFileOutputFolder]: tl.getVariable(Constants.outputFileFolder),
  };

  // Pass task variable to sub process
  let tlVariables = tl.getVariables();
  for (let v of tlVariables) {
    // The variables in VSTS build contains dot, need to convert to underscore.
    let name = v.name.replace('.', '_').toUpperCase();
    if (!envList[name]) {
      envList[name] = v.value;
    }
  }

  tl.debug(`Following variables will be passed to the iotedgedev command: ${JSON.stringify(envList)}`);

  let outputStream: EchoStream = new EchoStream();

  let execOptions: IExecOptions = {
    cwd: tl.cwd(),
    env: envList,
    outStream: outputStream as stream.Writable,
  } as IExecOptions;
  let defaultPlatform = tl.getInput('defaultPlatform', true);
  let command: string = `build`;
  command += ` --file ${templateFilePath}`;
  command += ` --platform ${defaultPlatform}`;
  await tl.exec(`${Constants.iotedgedev}`, command, execOptions);

  let outLog: string = outputStream.content;
  let filterReg: RegExp = /Expanding '[^']*' to '([^']*)'/g;
  let matches: RegExpMatchArray = filterReg.exec(outLog);
  if(matches && matches[1]) {
    tl.setVariable(Constants.outputVariableDeploymentPathKey, matches[1]);
    tl.setVariable('_' + Constants.outputVariableDeploymentPathKey, matches[1]);
    tl.debug(`Set ${Constants.outputVariableDeploymentPathKey} to ${matches[1]}`);
  }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:48,代码来源:buildimage.ts


示例3: usePyPy

function usePyPy(majorVersion: 2 | 3, parameters: TaskParameters, platform: Platform): void {
    const findPyPy = tool.findLocalTool.bind(undefined, 'PyPy', majorVersion.toString());
    let installDir: string | null = findPyPy(parameters.architecture);

    if (!installDir && platform === Platform.Windows) {
        // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
        // On Hosted VS2017, we only install an x86 version.
        // Fall back to x86.
        installDir = findPyPy('x86');
    }

    if (!installDir) {
        // PyPy not installed in $(Agent.ToolsDirectory)
        throw pypyNotFoundError(majorVersion);
    }

    // For PyPy, Windows uses 'bin', not 'Scripts'.
    const _binDir = path.join(installDir, 'bin');

    // On Linux and macOS, the Python interpreter is in 'bin'.
    // On Windows, it is in the installation root.
    const pythonLocation = platform === Platform.Windows ? installDir : _binDir;
    task.setVariable('pythonLocation', pythonLocation);

    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);
        toolUtil.prependPathSafe(_binDir);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:29,代码来源:usepythonversion.ts


示例4: run

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

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

        tl.prependPath(installationPath);

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

        // 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");
    }

    // Install NuGet version specified by user or 4.4.1 in case none is specified
    // Also sets up the proxy configuration settings.
    const nugetVersion = tl.getInput('nugetVersion') || '4.4.1';
    await NuGetInstaller.installNuGet(nugetVersion);

    // Add dot net tools path to "PATH" environment variables, so that tools can be used directly.
    addDotNetCoreToolPath();
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:42,代码来源:usedotnet.ts


示例5: createOrAppendDockerCredentials

  public static createOrAppendDockerCredentials(registryAuthenticationToken: RegistryCredential): void {
    let creVar = tl.getVariable(Constants.fileNameDockerCredential);

    let credentials = creVar ? JSON.parse(creVar) : [];
    if (registryAuthenticationToken) {
      credentials.push({
        username: registryAuthenticationToken.username,
        password: registryAuthenticationToken.password,
        address: registryAuthenticationToken.serverUrl
      });
    }
    tl.setVariable(Constants.fileNameDockerCredential, JSON.stringify(credentials));
  }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:13,代码来源:util.ts


示例6: useCpythonVersion

async function useCpythonVersion(parameters: Readonly<TaskParameters>, platform: Platform): Promise<void> {
    const desugaredVersionSpec = desugarDevVersion(parameters.versionSpec);
    const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
    task.debug(`Semantic version spec of ${parameters.versionSpec} is ${semanticVersionSpec}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticVersionSpec, parameters.architecture);
    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec, parameters.architecture),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            x86Versions,
            x64Versions,
            task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);
    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);
        toolUtil.prependPathSafe(binDir(installDir, platform))

        if (platform === Platform.Windows) {
            // Add --user directory
            // `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
            const version = path.basename(path.dirname(installDir));
            const major = semver.major(version);
            const minor = semver.minor(version);

            const userScriptsDir = path.join(process.env['APPDATA'], 'Python', `Python${major}${minor}`, 'Scripts');
            toolUtil.prependPathSafe(userScriptsDir);
        }
        // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:45,代码来源:usepythonversion.ts


示例7: registerAdvinst

async function registerAdvinst(toolRoot: string, license: string): Promise<void> {
  if (!license)
    return;

  console.log(taskLib.loc("AI_RegisterTool"))

  let toolVersion: string = fileInfo.getFileVersion(path.join(toolRoot, advinstToolExecutable));
  let registrationCmd: string = "/RegisterCI";
  if (cmpVer.lt(advinstRegVersionSwitch, toolVersion) < 0) {
    registrationCmd = "/Register";
  }

  let execResult = taskLib.execSync(path.join(toolRoot, advinstToolCmdLineUtility), [registrationCmd, license]);
  if (execResult.code != 0) {
    throw new Error(taskLib.loc("AI_RegisterToolFailed", execResult.stdout));
  }
  let licensePath = path.join(taskLib.getVariable('ProgramData'), advinstLicenseSubPath);
  taskLib.checkPath(licensePath, taskLib.loc("AI_AdvinstLicenseFile"));
  taskLib.setVariable('advinst.cleanup', 'true');
}
开发者ID:Caphyon,项目名称:advinst-vsts-task,代码行数:20,代码来源:AdvinstTool.ts


示例8: getTfx

async function getTfx(versionSpec: string, checkLatest: boolean) {
    if (toolLib.isExplicitVersion(versionSpec)) {
        checkLatest = false; // check latest doesn't make sense when explicit version
    }

    let toolPath: string;
    if (!checkLatest) {
        toolPath = toolLib.findLocalTool('tfx', versionSpec);
    }

    if (!toolPath) {
        let version: string;
        if (toolLib.isExplicitVersion(versionSpec)) {
            version = versionSpec;
        }
        else {
            version = queryLatestMatch(versionSpec);
            if (!version) {
                throw new Error(`Unable to find Tfx version '${versionSpec}'`);
            }

            toolPath = toolLib.findLocalTool('tfx', version);
        }

        if (!toolPath) {
            toolPath = await acquireTfx(version);
        }
    }

    if (os.platform() !== "win32")
    {
        toolPath = path.join(toolPath, "/node_modules/.bin/");
    }
    
    taskLib.setVariable("__tfxpath", toolPath, false);
    toolLib.prependPath(toolPath);
}
开发者ID:Microsoft,项目名称:vsts-extension-build-release-tasks,代码行数:37,代码来源:TfxInstaller.ts


示例9: setVsTestToolLocation

export function setVsTestToolLocation(toolPath: string) {
    // Set the task variable so that the VsTest task can consume this path
    tl.setVariable('VsTestToolsInstallerInstalledToolLocation', toolPath);
    console.log(tl.loc('InstallationSuccessful', toolPath));
    tl.debug(`Set variable VsTestToolsInstallerInstalledToolLocation value to ${toolPath}.`);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:6,代码来源:helpers.ts


示例10: if


//.........这里部分代码省略.........
                || extensionTag
                || extensionName
                || (extensionPricing && extensionPricing !== "default")
                || (extensionVisibility && extensionVisibility !== "default")
                || extensionVersion
                || updateTasksId ) {

                tl.debug("Start editing of VSIX");
                const ve = new vsixeditor.VSIXEditor(vsixFile, vsixOutput);
                ve.startEdit();

                if (publisher) { ve.editPublisher(publisher); }
                if (extensionId) { ve.editId(extensionId); }
                if (extensionTag) { ve.editIdTag(extensionTag); }
                if (extensionName) { ve.editExtensionName(extensionName); }
                if (extensionVisibility) { ve.editExtensionVisibility(extensionVisibility); }
                if (extensionPricing) { ve.editExtensionPricing(extensionPricing); }
                if (extensionVersion) {
                    ve.editVersion(extensionVersion);
                    ve.editUpdateTasksVersion(updateTasksVersion);
                }
                if (updateTasksId) {
                    ve.editUpdateTasksId(updateTasksId);
                }

                const vsixGeneratedFile = await ve.endEdit();
                tfx.arg(["--vsix", vsixGeneratedFile]);
                vsixOutput = vsixGeneratedFile;
            }
            else {
                vsixOutput = vsixFile;
                tfx.arg(["--vsix", vsixOutput]);
            }
        } 

        // Share with
        const shareWith = tl.getDelimitedInput("shareWith", ",", false).map((value) => { return value.trim(); });
        const extensionVisibility = tl.getInput("extensionVisibility", false) || "";
        const connectTo = tl.getInput("connectTo", true);
        if (shareWith) {
            if (connectTo === "TFS") {
                tl.warning("Ignoring Share - Not available on TFS.");
            }
            else if (extensionVisibility.indexOf("public") < 0) {
                // Only handle shareWith if the extension is not public
                tfx.argIf(shareWith && shareWith.length > 0, ["--share-with"].concat(shareWith));
            } else if (shareWith && shareWith.length > 0) {
                tl.warning("Ignoring Share - Not available on public extensions.");
            }
        }

        const noWaitValidation = tl.getBoolInput("noWaitValidation", false);
        if (noWaitValidation) {
            tl.debug(`Not waiting for validation.`);
            tfx.arg("--no-wait-validation");
        }

        const bypassLocalValidation = tl.getBoolInput("bypassLocalValidation", false);
        if (bypassLocalValidation) {
            tl.debug(`Bypassing local validation.`);
            tfx.arg("--bypass-validation");
        }

        const args = tl.getInput("arguments", false);
        if (args) {
            tl.debug(`Adding additional arguments: ${args}.`);
            tfx.line(args);
        }

        tl.debug(`Redirecting output to stderr.`);
        tfx.arg(['--debug-log-stream', 'stderr']);

        tl.debug(`Run tfx.`);
        const outputStream = new common.TfxJsonOutputStream(console.log);
        const errorStream = new common.TfxJsonOutputStream(tl.error);
        
        const code = await tfx.exec({ outStream: outputStream, errorStream: errorStream, failOnStdErr: false } as any);
        const json = JSON.parse(outputStream.jsonString);

        if (json && json.published) {
            const publishedVsix = fileType === "manifest" ? json.packaged : vsixOutput;

            if (outputVariable) {
                tl.setVariable(outputVariable, publishedVsix);
            }

            console.log(`Published VSIX: ${publishedVsix}.`);
            tl.setResult(tl.TaskResult.Succeeded, `tfx exited with return code: ${code}`);
        }
        else
        {
            tl.setResult(tl.TaskResult.Failed, `Publishing failed`);    
        }
    }catch (err) {
        tl.setResult(tl.TaskResult.Failed, `tfx failed with error: ${err}`);
    } finally {
        if (cleanupTfxArgs) { cleanupTfxArgs(); }
    }
    return Promise.resolve(true);
});
开发者ID:Microsoft,项目名称:vsts-extension-build-release-tasks,代码行数:101,代码来源:PublishExtension.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript task.stats函数代码示例发布时间:2022-05-25
下一篇:
TypeScript task.setResult函数代码示例发布时间: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