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

TypeScript task.setResult函数代码示例

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

本文整理汇总了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}`);
        }
    });
开发者ID:Microsoft,项目名称:vsts-extension-build-release-tasks,代码行数:35,代码来源:IsValidExtension.ts


示例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);
  }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:30,代码来源:index.ts


示例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);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:58,代码来源:vstestplatformtoolinstaller.ts


示例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);
    }
})();
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:14,代码来源:main.ts


示例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;
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:35,代码来源:npm.ts


示例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);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:35,代码来源:androidsigning.ts


示例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;
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:45,代码来源:nugetcommandmain.ts


示例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}`);
    }
});
开发者ID:Microsoft,项目名称:vsts-extension-build-release-tasks,代码行数:18,代码来源:ShareExtension.ts


示例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.`);
   }
 }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:9,代码来源:util.ts


示例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, '');
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:12,代码来源:nugettoolinstaller.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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