本文整理汇总了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 '';
})
示例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;
}
}
示例3:
}).stderr.on('data', (data) => {
stdErrWritten = true;
tl.debug('stderr = ' + data);
if (data && data.toString().trim() !== '') {
tl.error(data);
}
});
示例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);
}
}
示例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));
}
}
}
}
示例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);
}
}
示例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, "");
}
}
示例8: tryDeleteFile
function tryDeleteFile(filePath: string): void {
if (fs.existsSync(filePath)) {
try {
fs.unlinkSync(filePath);
} catch (err) {
tl.error(err.message);
}
}
}
示例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'));
}
}
示例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'));
}
}