本文整理汇总了TypeScript中azure-pipelines-task-lib/task.getVariable函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getVariable函数的具体用法?TypeScript getVariable怎么用?TypeScript getVariable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getVariable函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
async function main(): Promise<void> {
var feed = getProjectAndFeedIdFromInputParam("feed");
if(feed.projectId) {
throw new Error(tl.loc("UnsupportedProjectScopedFeeds"));
}
let feedId = feed.feedId;
let regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
let packageId = tl.getInput("definition");
if(!regexGuid.test(packageId)){
packageId = "Nuget_" + tl.getInput("definition");
}
let version = tl.getInput("version");
let downloadPath = tl.getInput("downloadPath");
let collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri");
var accessToken = getAuthToken();
var credentialHandler = vsts.getBearerHandler(accessToken);
var vssConnection = new vsts.WebApi(collectionUrl, credentialHandler);
var coreApi = vssConnection.getCoreApi();
const retryLimitValue: string = tl.getVariable("VSTS_HTTP_RETRY");
const retryLimit: number = (!!retryLimitValue && !isNaN(parseInt(retryLimitValue))) ? parseInt(retryLimitValue) : 4;
tl.debug(`RetryLimit set to ${retryLimit}`);
await executeWithRetries("downloadPackage", () => downloadPackage(collectionUrl, accessToken, credentialHandler, feedId, packageId, version, downloadPath).catch((reason) => {
throw reason;
}), retryLimit);
}
示例2: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, 'task.json'));
let packagingLocation: pkgLocationUtils.PackagingLocation;
try {
packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.Npm);
} catch (error) {
tl.debug('Unable to get packaging URIs, using default collection URI');
tl.debug(JSON.stringify(error));
const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri');
packagingLocation = {
PackagingUris: [collectionUrl],
DefaultPackagingUri: collectionUrl
};
}
const forcedUrl = tl.getVariable('Npm.PackagingCollectionUrl');
if (forcedUrl) {
packagingLocation.DefaultPackagingUri = forcedUrl;
packagingLocation.PackagingUris.push(forcedUrl);
}
await _logNpmStartupVariables(packagingLocation);
const command = tl.getInput(NpmTaskInput.Command);
switch (command) {
case NpmCommand.Install:
return npmCustom.run(packagingLocation, NpmCommand.Install);
case NpmCommand.Publish:
return npmPublish.run(packagingLocation);
case NpmCommand.Custom:
return npmCustom.run(packagingLocation);
default:
tl.setResult(tl.TaskResult.Failed, tl.loc('UnknownCommand', command));
return;
}
}
示例3: getDefaultProps
function getDefaultProps() {
return {
releaseuri: tl.getVariable('Release.ReleaseUri'),
releaseid: tl.getVariable('Release.ReleaseId'),
builduri: tl.getVariable('Build.BuildUri'),
buildid: tl.getVariable('Build.Buildid')
};
}
示例4: getTempPath
export function getTempPath(): string {
const tempNpmrcDir
= tl.getVariable('Agent.BuildDirectory')
|| tl.getVariable('Agent.TempDirectory');
const tempPath = path.join(tempNpmrcDir, 'npm');
if (tl.exist(tempPath) === false) {
tl.mkdirP(tempPath);
}
return tempPath;
}
示例5: shouldUseVstsNuGetPush
function shouldUseVstsNuGetPush(isInternalFeed: boolean, conflictsAllowed: boolean, nugetExePath: string): boolean {
if (tl.osType() !== "Windows_NT"){
tl.debug("Running on a non-windows platform so NuGet.exe will be used.");
return false;
}
if (!isInternalFeed)
{
tl.debug("Pushing to an external feed so NuGet.exe will be used.");
return false;
}
if (commandHelper.isOnPremisesTfs())
{
tl.debug("Pushing to an onPrem environment, only NuGet.exe is supported.");
if(conflictsAllowed){
tl.warning(tl.loc("Warning_AllowDuplicatesOnlyAvailableHosted"));
}
return false;
}
const nugetOverrideFlag = tl.getVariable("NuGet.ForceNuGetForPush");
if (nugetOverrideFlag === "true") {
tl.debug("NuGet.exe is force enabled for publish.");
if(conflictsAllowed)
{
tl.warning(tl.loc("Warning_ForceNuGetCannotSkipConflicts"));
}
return false;
}
if (nugetOverrideFlag === "false") {
tl.debug("NuGet.exe is force disabled for publish.");
return true;
}
const vstsNuGetPushOverrideFlag = tl.getVariable("NuGet.ForceVstsNuGetPushForPush");
if (vstsNuGetPushOverrideFlag === "true") {
tl.debug("VstsNuGetPush.exe is force enabled for publish.");
return true;
}
if (vstsNuGetPushOverrideFlag === "false") {
tl.debug("VstsNuGetPush.exe is force disabled for publish.");
if(conflictsAllowed)
{
tl.warning(tl.loc("Warning_ForceNuGetCannotSkipConflicts"));
}
return false;
}
return true;
}
示例6: getPypircPath
export function getPypircPath(): string {
let pypircPath: string;
if (tl.getVariable("PYPIRC_PATH")) {
pypircPath = tl.getVariable("PYPIRC_PATH");
}
else {
let tempPath = tl.getVariable("Agent.TempDirectory");
tempPath = path.join(tempPath, "twineAuthenticate");
tl.mkdirP(tempPath);
let savePypircPath = fs.mkdtempSync(tempPath + path.sep);
pypircPath = savePypircPath + path.sep + ".pypirc";
}
return pypircPath;
}
示例7: setupIotedgedev
public static setupIotedgedev(): void {
try {
let result = tl.execSync(`${Constants.iotedgedev}`, `--version`, Constants.execSyncSilentOption);
if (result.code === 0) {
console.log(tl.loc('DependencyAlreadyInstalled', Constants.iotedgedev, result.stdout.substring(result.stdout.indexOf("version"))));
return;
}
} catch (e) {
// If exception, it means iotedgedev is not installed. Do nothing.
}
let cmds: Cmd[] = [];
let version = Constants.iotedgedevDefaultVersion;
if (tl.getVariable(Constants.iotedgedevLockVersionKey)) {
version = tl.getVariable(Constants.iotedgedevLockVersionKey);
}
tl.debug(`The specified iotedgedev version is: ${version}`);
if (tl.osType() === Constants.osTypeLinux) {
cmds = [
{ path: `sudo`, arg: `apt-get update`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `apt-get install -y python-setuptools`, execOption: Constants.execSyncSilentOption },
{ path: `sudo`, arg: `pip install ${Constants.iotedgedev}==${version}`, execOption: Constants.execSyncSilentOption },
]
} else if (tl.osType() === Constants.osTypeWindows) {
cmds = [
{ path: `pip`, arg: `install ${Constants.iotedgedev}==${version}`, execOption: Constants.execSyncSilentOption },
]
}
try {
for (let cmd of cmds) {
let result = tl.execSync(cmd.path, cmd.arg, cmd.execOption);
if (result.code !== 0) {
tl.debug(result.stderr);
}
}
} catch (e) {
// If exception, record error message to debug
tl.debug(e);
}
let result = tl.execSync(`${Constants.iotedgedev}`, `--version`, Constants.execSyncSilentOption);
if (result.code === 0) {
console.log(tl.loc('DependencyInstallSuccess', Constants.iotedgedev, result.stdout.substring(result.stdout.indexOf("version"))));
} else {
throw Error(tl.loc('DependencyInstallFail', Constants.iotedgedev));
}
}
示例8: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// If this is not the structure, there may also be two files located at:
// /dist/v0.12.18/node.exe
// /dist/v0.12.18/node.lib
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
catch (err) {
if (err['httpStatusCode'] &&
err['httpStatusCode'] === '404')
{
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
else {
throw err;
}
}
return await toolLib.cacheDir(tempDir, 'node', version);
}
示例9: isServerBasedRun
function isServerBasedRun(): boolean {
const batchType = tl.getInput('distributionBatchType');
if (batchType && batchType === 'basedOnTestCases') {
const batchSize = tl.getInput('batchingBasedOnAgentsOption');
if (batchSize && batchSize === 'customBatchSize') {
return true;
}
} else if (batchType && batchType === 'basedOnExecutionTime') {
return true;
} else if (batchType && batchType === 'basedOnAssembly') {
return true;
}
const testType = tl.getInput('testSelector');
tl.debug('Value of Test Selector :' + testType);
if (testType.toLowerCase() === 'testplan' || testType.toLowerCase() === 'testrun') {
return true;
}
const parallelExecution = tl.getVariable('System.ParallelExecutionType');
tl.debug('Value of ParallelExecutionType :' + parallelExecution);
if (parallelExecution && parallelExecution.toLowerCase() === 'multimachine') {
const dontDistribute = tl.getBoolInput('dontDistribute');
if (dontDistribute) {
return false;
}
return true;
}
return false;
}
示例10: acquireTfx
async function acquireTfx(version: string): Promise<string> {
try{
version = toolLib.cleanVersion(version);
let extPath: string;
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, 'tfx'); // use as short a path as possible due to nested node_modules folders
taskLib.mkdirP(path.join(extPath));
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["install", "tfx-cli@" + version, "--prefix", extPath]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
if (os.platform() === "win32")
{
fs.unlinkSync(path.join(extPath, "/tfx"));
}
return await toolLib.cacheDir(extPath, 'tfx', version);
}
}
catch {
return Promise.reject(new Error("Failed to install tfx"));
}
}