本文整理汇总了TypeScript中azure-pipelines-task-lib/task.setResult函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setResult函数的具体用法?TypeScript setResult怎么用?TypeScript setResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setResult函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: promiseRetry
await common.runTfx(async tfx => {
try
{
tfx.arg(["extension", "isvalid", "--json", "--no-color"]);
common.setTfxMarketplaceArguments(tfx);
common.validateAndSetTfxManifestArguments(tfx);
const options = {
retries: +tl.getInput("maxRetries", false) || 10,
factor: 1,
minTimeout: 1000 * 60 * (+tl.getInput("minTimeout", false) || 1),
maxTimeout: 1000 * 60 * (+tl.getInput("maxTimeout", false) || 15),
randomize: false
};
await promiseRetry(options,
(retry, attempt) => {
tl.debug(`Attempt: ${attempt}`);
const result = tfx.execSync({ silent: false, failOnStdErr: false } as any);
const json = JSON.parse(result.stdout);
switch (json.status) {
case "pending":
return retry(json.status);
case "success":
return json.status;
default:
throw json.status;
}
});
tl.setResult(tl.TaskResult.Succeeded, "Extension is valid.");
} catch (err) {
tl.setResult(tl.TaskResult.Failed, `Extension validation failed: ${err}`);
}
});
示例2: run
async function run() {
try {
if (action === 'Build module images') {
console.log(tl.loc('BuildingModules'));
await BuildImage.run();
console.log(tl.loc('BuildingModulesFinished'));
} else if (action === 'Push module images') {
console.log(tl.loc('PushingModules'));
telemetryEvent.isACR = tl.getInput("containerregistrytype", true) === "Azure Container Registry";
await PushImage.run();
console.log(tl.loc('PushingModulesFinished'));
} else if (action === 'Deploy to IoT Edge devices') {
console.log(tl.loc('StartDeploy'));
telemetryEvent.hashIoTHub = util.sha256(tl.getInput("iothubname", true));
await DeployImage.run(telemetryEvent);
console.log(tl.loc('FinishDeploy'));
}
telemetryEvent.isSuccess = true;
tl.setResult(tl.TaskResult.Succeeded, "");
} catch (e) {
telemetryEvent.isSuccess = false;
tl.setResult(tl.TaskResult.Failed, e)
} finally {
telemetryEvent.taskTime = (+new Date() - (+startTime)) / 1000;
if (telemetryEnabled) {
trackEvent(action, telemetryEvent);
}
commonTelemetry.emitTelemetry('TaskEndpointId', "AzureIoTEdgeV2", telemetryEvent);
}
}
示例3: startInstaller
// First function to be invoke starting the installation
async function startInstaller() {
try {
console.log(tl.loc('StartingInstaller'));
console.log('==============================================================================');
const osPlat: string = os.platform();
ci.addToConsolidatedCi('operatingSystem', osPlat);
ci.addToConsolidatedCi('result', constants.installationStatusFailed);
// Fail the task if os is not windows
if (osPlat !== 'win32') {
ci.addToConsolidatedCi('failureReason', constants.unsupportedOS);
tl.setResult(tl.TaskResult.Failed, tl.loc('OnlyWindowsOsSupported'));
return;
}
// Read task inputs
const packageFeedSelectorInput = tl.getInput(constants.packageFeedSelector, true);
const versionSelectorInput = tl.getInput(constants.versionSelector, false);
const testPlatformVersion = tl.getInput(constants.testPlatformVersion, false);
const networkSharePath = tl.getInput(constants.netShare, false);
const username = tl.getInput(constants.username, false);
const password = tl.getInput(constants.password, false);
const packageSource = constants.defaultPackageSource;
ci.addToConsolidatedCi('packageFeedSelectorInput', packageFeedSelectorInput);
tl.debug(`Selected package feed: ${packageFeedSelectorInput}`);
switch (packageFeedSelectorInput.toLowerCase()) {
case 'nugetorg':
tl.debug('Going via nuget org download flow.');
await new NugetFeedInstaller()
.installVsTestPlatformToolFromSpecifiedFeed(packageSource, testPlatformVersion, versionSelectorInput, null);
break;
case 'customfeed':
tl.debug('Going via custom feed download flow.');
await new NugetFeedInstaller()
.installVsTestPlatformToolFromCustomFeed(packageSource, versionSelectorInput, testPlatformVersion, username, password);
break;
case 'netshare':
tl.debug('Going via net share copy flow.');
await new NetworkShareInstaller().installVsTestPlatformToolFromNetworkShare(networkSharePath);
break;
}
} catch (error) {
ci.publishEvent('Completed', { isSetupSuccessful: 'false' } );
tl.setResult(tl.TaskResult.Failed, error);
return;
}
ci.addToConsolidatedCi('result', constants.installationStatusSucceeded);
}
示例4: usePythonVersion
(async () => {
try {
task.setResourcePath(path.join(__dirname, 'task.json'));
await usePythonVersion({
versionSpec: task.getInput('versionSpec', true),
addToPath: task.getBoolInput('addToPath', true),
architecture: task.getInput('architecture', true)
},
getPlatform());
task.setResult(task.TaskResult.Succeeded, "");
} catch (error) {
task.setResult(task.TaskResult.Failed, error.message);
}
})();
示例5: 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;
}
}
示例6: run
async function run() {
try {
// Configure localization
tl.setResourcePath(path.join(__dirname, 'task.json'));
// Get files to be signed
const filesPattern: string = tl.getInput('files', true);
// Signing the APK?
const apksign: boolean = tl.getBoolInput('apksign');
// Zipaligning the APK?
const zipalign: boolean = tl.getBoolInput('zipalign');
// Resolve files for the specified value or pattern
const filesToSign: string[] = tl.findMatch(null, filesPattern);
// Fail if no matching files were found
if (!filesToSign || filesToSign.length === 0) {
throw new Error(tl.loc('NoMatchingFiles', filesPattern));
}
for (const file of filesToSign) {
if (zipalign) {
await zipaligning(file);
}
if (apksign) {
await apksigning(file);
}
}
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err);
}
}
示例7: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, "task.json"));
// Getting NuGet
tl.debug("Getting NuGet");
let nuGetPath: string;
let nugetVersion: string;
try {
nuGetPath = tl.getVariable(nuGetGetter.NUGET_EXE_TOOL_PATH_ENV_VAR)
|| tl.getVariable(NUGET_EXE_CUSTOM_LOCATION);
if (!nuGetPath) {
const cachedVersionToUse = await nuGetGetter.cacheBundledNuGet();
nuGetPath = await nuGetGetter.getNuGet(cachedVersionToUse);
}
const nugetVersionInfo: VersionInfo = await peParser.getFileVersionInfoAsync(nuGetPath);
if (nugetVersionInfo && nugetVersionInfo.fileVersion){
nugetVersion = nugetVersionInfo.fileVersion.toString();
}
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, error.message);
return;
} finally{
_logNugetStartupVariables(nuGetPath, nugetVersion);
}
const nugetCommand = tl.getInput("command", true);
switch (nugetCommand) {
case "restore":
nugetRestore.run(nuGetPath);
break;
case "pack":
nugetPack.run(nuGetPath);
break;
case "push":
nugetPublish.run(nuGetPath);
break;
case "custom":
nugetCustom.run(nuGetPath);
break;
default:
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_CommandNotRecognized", nugetCommand));
break;
}
}
示例8: catch
void common.runTfx(async tfx => {
tfx.arg(["extension", "share", "--no-color"]);
common.setTfxMarketplaceArguments(tfx);
common.validateAndSetTfxManifestArguments(tfx);
// Installation targets
const accounts = tl.getDelimitedInput("accounts", ",", true);
tfx.arg(["--share-with"].concat(accounts).map((value, index) => { return value.trim(); }));
try{
const code = await tfx.exec();
tl.setResult(tl.TaskResult.Succeeded, `tfx exited with return code: ${code}`);
} catch (err)
{
tl.setResult(tl.TaskResult.Failed, `tfx failed with error: ${err}`);
}
});
示例9: setTaskRootPath
public static setTaskRootPath(root: string): void {
try {
tl.pushd(root);
tl.debug(`Task root path set to ${root}`);
} catch (e) {
console.log(tl.loc('RootPathNotExist', root));
tl.setResult(tl.TaskResult.Failed, `The Root path ${root} does not exist.`);
}
}
示例10: run
async function run() {
try {
taskLib.setResourcePath(path.join(__dirname, 'task.json'));
const versionSpec = taskLib.getInput('versionSpec', false) || DEFAULT_NUGET_VERSION;
const checkLatest = taskLib.getBoolInput('checkLatest', false);
await nuGetGetter.getNuGet(versionSpec, checkLatest, true);
} catch (error) {
console.error('ERR:' + error.message);
taskLib.setResult(taskLib.TaskResult.Failed, '');
}
}