當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task.error函數代碼示例

本文整理匯總了TypeScript中vsts-task-lib/task.error函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript error函數的具體用法?TypeScript error怎麽用?TypeScript error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了error函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

	.fail(err => {
		tl.error(tl.loc("CouldNotFindServiceEndpoint", area));
		tl.error(err);
		tl.exit(1);
		return '';

	})
開發者ID:ivyzhu,項目名稱:vsts-tasks,代碼行數:7,代碼來源:LocationHelpers.ts

示例2: getVsTestRunnerDetails

export function getVsTestRunnerDetails(testConfig: models.TestConfigurations) {
    const vstestexeLocation = locateVSTestConsole(testConfig);
    const vstestLocationEscaped = vstestexeLocation.replace(/\\/g, '\\\\');
    const wmicTool = tl.tool('wmic');
    const wmicArgs = ['datafile', 'where', 'name=\''.concat(vstestLocationEscaped, '\''), 'get', 'Version', '/Value'];
    wmicTool.arg(wmicArgs);
    let output = wmicTool.execSync({ silent: true } as tr.IExecSyncOptions).stdout;

    if (utils.Helper.isNullOrWhitespace(output)) {
        tl.error(tl.loc('ErrorReadingVstestVersion'));
        throw new Error(tl.loc('ErrorReadingVstestVersion'));
    }
    output = output.trim();
    tl.debug('VSTest Version information: ' + output);
    const verSplitArray = output.split('=');
    if (verSplitArray.length !== 2) {
        tl.error(tl.loc('ErrorReadingVstestVersion'));
        throw new Error(tl.loc('ErrorReadingVstestVersion'));
    }

    const versionArray = verSplitArray[1].split('.');
    if (versionArray.length !== 4) {
        tl.warning(tl.loc('UnexpectedVersionString', output));
        throw new Error(tl.loc('UnexpectedVersionString', output));
    }

    const majorVersion = parseInt(versionArray[0]);
    const minorVersion = parseInt(versionArray[1]);
    const patchNumber = parseInt(versionArray[2]);

    ci.publishEvent({ testplatform: `${majorVersion}.${minorVersion}.${patchNumber}` });

    if (isNaN(majorVersion) || isNaN(minorVersion) || isNaN(patchNumber)) {
        tl.warning(tl.loc('UnexpectedVersionNumber', verSplitArray[1]));
        throw new Error(tl.loc('UnexpectedVersionNumber', verSplitArray[1]));
    }

    switch (majorVersion) {
        case 14:
            testConfig.vsTestVersionDetails = new version.Dev14VSTestVersion(vstestexeLocation, minorVersion, patchNumber);
            break;
        case 15:
            testConfig.vsTestVersionDetails = new version.Dev15VSTestVersion(vstestexeLocation, minorVersion, patchNumber);
            break;
        default:
            testConfig.vsTestVersionDetails = new version.VSTestVersion(vstestexeLocation, majorVersion, minorVersion, patchNumber);
            break;
    }
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:49,代碼來源:versionfinder.ts

示例3:

 }).stderr.on('data', (data) => {
     stdErrWritten = true;
     tl.debug('stderr = ' + data);
     if (data && data.toString().trim() !== '') {
         tl.error(data);
     }
 });
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:7,代碼來源:ssh2helpers.ts

示例4: installVsTestPlatformToolFromCustomFeed

    // Installs the test platform from a custom feed provided by the user along with credentials for authentication against said feed
    public async installVsTestPlatformToolFromCustomFeed(packageSource: string, versionSelectorInput: string, testPlatformVersion: string, username: string, password: string) {
        let tempConfigFilePath = null;
        try {
            try {
                if (!helpers.isNullEmptyOrUndefined(password)) {
                    tl.debug('Attempting to write feed details along with provided credentials to temporary config file.');
                    tempConfigFilePath = helpers.GenerateTempFile(`${uuid.v1()}.config`);
                    const feedId = uuid.v1();
                    this.prepareNugetConfigFile(packageSource, tempConfigFilePath, username, password, feedId);
                    packageSource = feedId;
                    ci.addToConsolidatedCi('passwordProvided', 'true');
                    ci.addToConsolidatedCi('usernameProvided', `${!helpers.isNullEmptyOrUndefined(username)}`);
                } else {
                    packageSource = tl.getInput(constants.customFeed);
                    tl.debug(`Credentials were not provided. Skipping writing to config file. Will use custom package feed provided by user ${packageSource}`);
                }
            } catch (error) {
                tl.error(error);
                console.log(tl.loc('LatestStableCached'));
                // Look for the latest stable version available in the cache as a fallback.
                testPlatformVersion = 'x';
                tempConfigFilePath = null;
            }

            await this.installVsTestPlatformToolFromSpecifiedFeed(packageSource, testPlatformVersion, versionSelectorInput, tempConfigFilePath);

        } finally {
            helpers.cleanUpTempConfigFile(tempConfigFilePath);
        }
    }
開發者ID:shubham90,項目名稱:vsts-tasks,代碼行數:31,代碼來源:nugetfeedinstaller.ts

示例5: createAgent

 public static async createAgent(environment: models.DtaEnvironment, retries: number) {
     var currentRetryCount = retries;
     while(currentRetryCount > 0) {
         currentRetryCount--;
         try {
             const envUrlRef: any = { Url: environment.environmentUri };
             const machineNameRef: any = { Name: environment.agentName };
             // TODO : Change any to appropriate types once promiseme package is avialable
             const testAgent: any = {
                                 Name: environment.agentName,
                                 Capabilities: [],
                                 DtlEnvironment: envUrlRef,
                                 DtlMachine: machineNameRef };
             const webapi: any = new webapim.WebApi(environment.tfsCollectionUrl, webapim.getBearerHandler(environment.patToken));
             const testApi: any = webapi.getTestApi();
             const registeredAgent = await testApi.createAgent(testAgent);
             tl.debug('created the test agent entry in DTA service, id : ' + registeredAgent.id);
             return registeredAgent.id;
         } catch (error) {
             tl.error('Error : created the test agent entry in DTA service, so retrying => retries pending  : ' + currentRetryCount
                     + 'error details :' + error);
             if(currentRetryCount === 0) {
                 throw new Error(tl.loc("configureDtaAgentFailed", retries, error));
             }
         }
     }
 }
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:27,代碼來源:testagent.ts

示例6: run

async function run() {
    try {
        const connection = utils.getDefaultOctopusConnectionDetailsOrThrow();
        
        const space = tasks.getInput("Space");
        const packages = utils.getLineSeparatedItems(tasks.getInput("Package", true));
        const replace = tasks.getBoolInput("Replace");
        const additionalArguments = tasks.getInput("AdditionalArguments");

        const octo = await utils.getOrInstallOctoCommandRunner("push");
        const matchedPackages = await utils.resolveGlobs(packages);

        const configure = [
            connectionArguments(connection),
            argumentIfSet(argumentEnquote, "space", space),
            multiArgument(argumentEnquote, "package", matchedPackages),
            flag("replace-existing", replace),
            includeArguments(additionalArguments)
        ];

        const code:Number = await octo.map(x => x.launchOcto(configure))
            .getOrElseL((x) => { throw new Error(x); });

        tasks.setResult(tasks.TaskResult.Succeeded, "Succeeded with code " + code);
    }catch(err){
        tasks.error(err);
        tasks.setResult(tasks.TaskResult.Failed, "Failed to push package. " + err.message);
    }
}
開發者ID:OctopusDeploy,項目名稱:OctoTFS,代碼行數:29,代碼來源:index.ts

示例7: run

export async function run(nuGetPath: string): Promise<void> {
    nutil.setConsoleCodePage();

    let buildIdentityDisplayName: string = null;
    let buildIdentityAccount: string = null;

    let args: string = tl.getInput("arguments", false);

    const version = await peParser.getFileVersionInfoAsync(nuGetPath);
    if(version.productVersion.a < 3 || (version.productVersion.a <= 3 && version.productVersion.b < 5))
    {
        tl.setResult(tl.TaskResult.Failed, tl.loc("Info_NuGetSupportedAfter3_5", version.strings.ProductVersion));
        return;
    }

    try {
        let credProviderPath = nutil.locateCredentialProvider();

        // Clauses ordered in this way to avoid short-circuit evaluation, so the debug info printed by the functions
        // is unconditionally displayed
        const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
        const useCredProvider = ngToolRunner.isCredentialProviderEnabled(quirks) && credProviderPath;
        // useCredConfig not placed here: This task will only support NuGet versions >= 3.5.0 which support credProvider both hosted and OnPrem

        let accessToken = auth.getSystemAccessToken();
        let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
        let urlPrefixes = await locationHelpers.assumeNuGetUriPrefixes(serviceUri);
        tl.debug(`Discovered URL prefixes: ${urlPrefixes}`);

        // Note to readers: This variable will be going away once we have a fix for the location service for
        // customers behind proxies
        let testPrefixes = tl.getVariable("NuGetTasks.ExtraUrlPrefixesForTesting");
        if (testPrefixes) {
            urlPrefixes = urlPrefixes.concat(testPrefixes.split(";"));
            tl.debug(`All URL prefixes: ${urlPrefixes}`);
        }
        let authInfo = new auth.NuGetExtendedAuthInfo(new auth.InternalAuthInfo(urlPrefixes, accessToken, useCredProvider, false), []);
        let environmentSettings: ngToolRunner.NuGetEnvironmentSettings = {
            credProviderFolder: useCredProvider ? path.dirname(credProviderPath) : null,
            extensionsDisabled: true
        };

        let executionOptions = new NuGetExecutionOptions(
            nuGetPath,
            environmentSettings,
            args,
            authInfo);

        runNuGet(executionOptions);
    } catch (err) {
        tl.error(err);

        if (buildIdentityDisplayName || buildIdentityAccount) {
            tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
        }

        tl.setResult(tl.TaskResult.Failed, "");
    }
}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:59,代碼來源:nugetcustom.ts

示例8: tryDeleteFile

function tryDeleteFile(filePath: string): void {
    if (fs.existsSync(filePath)) {
        try {
            fs.unlinkSync(filePath);
        } catch (err) {
            tl.error(err.message);
        }
    }
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:9,代碼來源:ssh.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.error函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。