本文整理汇总了TypeScript中azure-pipelines-task-lib/task.error函数的典型用法代码示例。如果您正苦于以下问题:TypeScript error函数的具体用法?TypeScript error怎么用?TypeScript error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getVsTestRunnerDetails
export function getVsTestRunnerDetails(testConfig: models.TestConfigurations) {
const vstestexeLocation = locateVSTestConsole(testConfig);
// Temporary hack for 16.0. All this code will be removed once we migrate to the Hydra flow
if (testConfig.vsTestVersion === '16.0') {
testConfig.vsTestVersionDetails = new version.VSTestVersion(vstestexeLocation, 16, 0, 0);
return;
}
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:Microsoft,项目名称:vsts-tasks,代码行数:56,代码来源:versionfinder.ts
示例2: 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:Microsoft,项目名称:vsts-tasks,代码行数:27,代码来源:testagent.ts
示例3: 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:Microsoft,项目名称:vsts-tasks,代码行数:31,代码来源:nugetfeedinstaller.ts
示例4: attemptPackageDownload
// Attemps to download the package and on failure looks for the latest stable version already present in the cache
public async attemptPackageDownload(packageSource: string, testPlatformVersion: string, nugetConfigFilePath: string) : Promise<string> {
let vstestPlatformInstalledLocation;
try {
tl.debug(`Could not find ${constants.packageId}.${testPlatformVersion} in the tools cache. Fetching it from nuget.`);
// Download the required version and cache it
vstestPlatformInstalledLocation = await this.acquireAndCacheVsTestPlatformNuget(packageSource,
testPlatformVersion, nugetConfigFilePath);
} catch (error) {
tl.error(tl.loc('TestPlatformDownloadFailed', testPlatformVersion, error));
if ((tl.getInput(constants.packageFeedSelector) === constants.nugetOrg || tl.getInput(constants.packageFeedSelector) === constants.customFeed)
&& tl.getInput(constants.versionSelector) === constants.specificVersion) {
return null;
}
console.log(tl.loc('LatestStableCached'));
testPlatformVersion = 'x';
ci.addToConsolidatedCi('downloadSucceeded', 'false');
ci.publishEvent('DownloadFailed', { action: 'getLatestAvailableInCache', error: error } );
startTime = perf();
// Download failed, look for the latest version available in the cache
vstestPlatformInstalledLocation = toolLib.findLocalTool(constants.toolFolderName, testPlatformVersion);
ci.addToConsolidatedCi('secondCacheLookupTime', perf() - startTime);
// No version found in cache, fail the task
if (!vstestPlatformInstalledLocation || vstestPlatformInstalledLocation === 'undefined') {
ci.addToConsolidatedCi('secondCacheLookupSucceeded', 'false');
ci.addToConsolidatedCi('failureReason', constants.downloadFailed);
tl.error(tl.loc('NoPackageFoundInCache'));
throw new Error(tl.loc('FailedToAcquireTestPlatform'));
}
ci.addToConsolidatedCi('secondCacheLookupSucceeded', 'true');
}
return vstestPlatformInstalledLocation;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:43,代码来源:nugetdownloadhelper.ts
示例5: reject
}).catch((error) => {
if (currentRetryCount <= 0) {
tl.error(tl.loc("OperationFailed", operationName, error));
reject(error);
}
else {
console.log(tl.loc('RetryingOperation', operationName, currentRetryCount));
currentRetryCount = currentRetryCount - 1;
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject), 4 * 1000);
}
});
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:11,代码来源:download.ts
示例6: acquireAndCacheVsTestPlatformNuget
// Downloads and caches the test platform package
private async acquireAndCacheVsTestPlatformNuget(packageSource: string, testPlatformVersion: string, nugetConfigFilePath: string): Promise<string> {
testPlatformVersion = toolLib.cleanVersion(testPlatformVersion);
const nugetTool = tl.tool(path.join(__dirname, 'nuget.exe'));
let downloadPath = helpers.getTempFolder();
// Ensure Agent.TempDirectory is set
if (!downloadPath) {
throw new Error(tl.loc('ExpectedTempToBeSet'));
}
// Call out a warning if the agent work folder path is longer than 50 characters as anything longer may cause the download to fail
// Note: This upper limit was calculated for a particular test platform package version and is subject to change
if (tl.getVariable(constants.agentWorkFolder) && tl.getVariable(constants.agentWorkFolder).length > 50) {
ci.addToConsolidatedCi('agentWorkDirectoryPathTooLong', 'true');
tl.warning(tl.loc('AgentWorkDirectoryPathTooLong'));
}
// Use as short a path as possible due to nested folders in the package that may potentially exceed the 255 char windows path limit
downloadPath = path.join(downloadPath, constants.toolFolderName);
nugetTool.arg(constants.install).arg(constants.packageId).arg(constants.version).arg(testPlatformVersion).arg(constants.source)
.arg(packageSource).arg(constants.outputDirectory).arg(downloadPath).arg(constants.noCache).arg(constants.directDownload)
.argIf(nugetConfigFilePath, constants.configFile).argIf(nugetConfigFilePath, nugetConfigFilePath).arg(constants.noninteractive);
tl.debug(`Downloading Test Platform version ${testPlatformVersion} from ${packageSource} to ${downloadPath}.`);
startTime = perf();
const resultCode = await nugetTool.exec();
ci.addToConsolidatedCi('downloadTime', perf() - startTime);
tl.debug(`Nuget.exe returned with result code ${resultCode}`);
if (resultCode !== 0) {
tl.error(tl.loc('NugetErrorCode', resultCode));
throw new Error(tl.loc('DownloadFailed', resultCode));
}
// Install into the local tool cache
const toolRoot = path.join(downloadPath, constants.packageId + '.' + testPlatformVersion);
tl.debug(`Caching the downloaded folder ${toolRoot}.`);
startTime = perf();
const vstestPlatformInstalledLocation = await toolLib.cacheDir(toolRoot, constants.toolFolderName, testPlatformVersion);
ci.addToConsolidatedCi('cacheTime', perf() - startTime);
return vstestPlatformInstalledLocation;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:46,代码来源:nugetdownloadhelper.ts
示例7: getVersionFromChannel
private getVersionFromChannel(channelInformation: Channel, versionSpec: string, packageType: string, includePreviewVersions: boolean): Promise<VersionInfo> {
var releasesJsonUrl: string = channelInformation.releasesJsonUrl;
if (releasesJsonUrl) {
return this.httpCallbackClient.get(releasesJsonUrl)
.then((response: httpClient.HttpClientResponse) => {
return response.readBody();
})
.then((body: string) => {
var channelReleases = JSON.parse(body).releases;
let versionInfoList: VersionInfo[] = [];
channelReleases.forEach((release) => {
if (release && release[packageType] && release[packageType].version) {
try {
let versionInfo: VersionInfo = new VersionInfo(release[packageType], packageType);
versionInfoList.push(versionInfo);
}
catch (err) {
tl.debug(tl.loc("VersionInformationNotComplete", release[packageType].version, err));
}
}
});
let matchedVersionInfo = utils.getMatchingVersionFromList(versionInfoList, versionSpec, includePreviewVersions);
if (!matchedVersionInfo) {
console.log(tl.loc("MatchingVersionNotFound", packageType, versionSpec));
return null;
}
console.log(tl.loc("MatchingVersionForUserInputVersion", matchedVersionInfo.getVersion(), channelInformation.channelVersion, versionSpec))
return matchedVersionInfo;
})
.catch((ex) => {
tl.error(tl.loc("ErrorWhileGettingVersionFromChannel", versionSpec, channelInformation.channelVersion, JSON.stringify(ex)));
return null;
});
}
else {
tl.error(tl.loc("UrlForReleaseChannelNotFound", channelInformation.channelVersion));
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:42,代码来源:versionfetcher.ts
示例8: getLatestPackageVersionNumber
// Lists the latest version of the package available in the feed specified.
public getLatestPackageVersionNumber(packageSource: string, includePreRelease: boolean, nugetConfigFilePath: string): string {
const nugetTool = tl.tool(path.join(__dirname, 'nuget.exe'));
ci.addToConsolidatedCi('includePreRelease', `${includePreRelease}`);
// Only search by package id if the feed is the offial nuget feed, otherwise search by package name as not all feeds
// support searching by package id
nugetTool.arg(constants.list)
.argIf(packageSource === constants.defaultPackageSource , `packageid:${constants.packageId}`)
.argIf(packageSource !== constants.defaultPackageSource , `${constants.packageId}`)
.argIf(includePreRelease, constants.preRelease)
.arg(constants.noninteractive).arg(constants.source).arg(packageSource)
.argIf(nugetConfigFilePath, constants.configFile)
.argIf(nugetConfigFilePath, nugetConfigFilePath);
startTime = perf();
const result = nugetTool.execSync();
ci.addToConsolidatedCi('ListLatestPackageTime', perf() - startTime);
if (result.code !== 0 || !(result.stderr === null || result.stderr === undefined || result.stderr === '')) {
tl.error(tl.loc('NugetErrorCode', result.code));
ci.addToConsolidatedCi('listingPackagesFailed', 'true');
throw new Error(tl.loc('ListPackagesFailed', result.code, result.stderr, result.stdout));
}
const listOfPackages = result.stdout.split('\r\n');
let version: string;
// parse the version number from the output string
listOfPackages.forEach(nugetPackage => {
if (nugetPackage.split(' ')[0] === constants.packageId) {
version = nugetPackage.split(' ')[1];
return;
}
});
return version;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:40,代码来源:nugetpackageversionhelper.ts
示例9: setKeyPartitionList
/**
* Set the partition_id ACL so codesign has permission to use the signing key.
*/
async function setKeyPartitionList(keychainPath: string, keychainPwd: string, privateKeyName: string) {
// security set-key-partition-list -S apple-tool:,apple: -s -l <privateKeyName> -k <keychainPwd> <keychainPath>
// n.b. This command could update multiple keys (e.g. an expired signing key and a newer signing key.)
if (privateKeyName) {
tl.debug(`Setting the partition_id ACL for ${privateKeyName}`);
// "If you'd like to run /usr/bin/codesign with the key, "apple:" must be an element of the partition list." - security(1) man page.
// When you sign into your developer account in Xcode on a new machine, you get a private key with partition list "apple:". However
// "security import a.p12 -k login.keychain" results in the private key with partition list "apple-tool:". I'm preserving import's
// "apple-tool:" and adding the "apple:" codesign needs.
const partitionList = 'apple-tool:,apple:';
let setKeyCommand: ToolRunner = tl.tool(tl.which('security', true));
setKeyCommand.arg(['set-key-partition-list', '-S', partitionList, '-s', '-l', privateKeyName, '-k', keychainPwd, keychainPath]);
// Watch for "unknown command". set-key-partition-list was added in Sierra (macOS v10.12)
let unknownCommandErrorFound: boolean;
let incorrectPasswordErrorFound: boolean;
setKeyCommand.on('errline', (line: string) => {
if (!unknownCommandErrorFound && line.includes('security: unknown command')) {
unknownCommandErrorFound = true;
}
});
try {
await setKeyCommand.exec();
} catch (err) {
if (unknownCommandErrorFound) {
// If we're on an older OS, we don't need to run set-key-partition-list.
console.log(tl.loc('SetKeyPartitionListCommandNotFound'));
} else {
tl.error(err);
throw new Error(tl.loc('SetKeyPartitionListCommandFailed'));
}
}
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:41,代码来源:ios-signing-common.ts
示例10: installVsTestPlatformToolFromSpecifiedFeed
// Installs the test platform from the feed specified. If platfornVersion is null then the versionSelectorInput is read and the version
// is determined accordingly. Additionally provide the config file to help with authentication if the feed is a custom feed.
public async installVsTestPlatformToolFromSpecifiedFeed(packageSource: string, testPlatformVersion: string, versionSelectorInput: string, nugetConfigFilePath: string) {
let vstestPlatformInstalledLocation: string;
let includePreRelease: boolean;
ci.addToConsolidatedCi('versionSelectorInput', versionSelectorInput);
tl.debug(`Using the package source ${packageSource} to get the ${constants.packageId} nuget package.`);
if (!helpers.isNullEmptyOrUndefined(nugetConfigFilePath)) {
tl.debug(`Using provided config file ${nugetConfigFilePath}.`);
}
if (versionSelectorInput.toLowerCase() === constants.latestStable) {
console.log(tl.loc('LookingForLatestStableVersion'));
testPlatformVersion = null;
includePreRelease = false;
} else if (versionSelectorInput.toLowerCase() === constants.latestPrerelease) {
console.log(tl.loc('LookingForLatestPreReleaseVersion'));
testPlatformVersion = null;
includePreRelease = true;
}
if (versionSelectorInput.toLowerCase() !== constants.specificVersion) {
try {
ci.addToConsolidatedCi('latestVersionIdentified', 'false');
testPlatformVersion = new NugetPackageVersionHelper()
.getLatestPackageVersionNumber(packageSource, includePreRelease, nugetConfigFilePath);
if (helpers.isNullEmptyOrUndefined(testPlatformVersion)) {
tl.warning(tl.loc('RequiredVersionNotListed'));
tl.debug('Looking for latest stable available version in cache.');
ci.publishEvent('RequestedVersionNotListed', { action: 'getLatestAvailableInCache' } );
// Look for the latest stable version available in the cache
testPlatformVersion = 'x';
} else {
ci.addToConsolidatedCi('latestVersionIdentified', 'true');
tl.debug(`Found the latest version to be ${testPlatformVersion}.`);
ci.publishEvent('RequestedVersionListed', { action: 'lookInCacheForListedVersion', version: testPlatformVersion } );
}
} catch (error) {
// Failed to list available versions, look for the latest stable version available in the cache
tl.error(`${tl.loc('FailedToListAvailablePackagesFromNuget')}\n${error}`);
tl.debug('Looking for latest stable version available version in cache.');
ci.publishEvent('RequestedVersionListFailed', { action: 'getLatestAvailableInCache', error: error } );
testPlatformVersion = 'x';
}
}
tl.debug(`Looking for version ${testPlatformVersion} in the tools cache.`);
startTime = perf();
// Check cache for the specified version
vstestPlatformInstalledLocation = toolLib.findLocalTool(constants.toolFolderName, testPlatformVersion);
ci.addToConsolidatedCi('cacheLookupTime', perf() - startTime);
// If found in the cache then set the tool location and return
if (!helpers.isNullEmptyOrUndefined(vstestPlatformInstalledLocation)) {
ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'true');
helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
return;
}
ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'false');
// If the testPlatformVersion is 'x' meaning listing failed and we were looking for a stable version in the cache
// and the cache lookup failed, then fail the task
if (!testPlatformVersion || testPlatformVersion === 'x') {
tl.error(tl.loc('NoPackageFoundInCache'));
ci.addToConsolidatedCi('failureReason', constants.listingFailed);
throw new Error(tl.loc('FailedToAcquireTestPlatform'));
}
// If the version provided is not an explicit version (ie contains containing wildcards) then throw
if (!toolLib.isExplicitVersion(testPlatformVersion)) {
ci.publishEvent('InvalidVersionSpecified', { version: testPlatformVersion } );
ci.addToConsolidatedCi('failureReason', constants.notExplicitVersion);
throw new Error(tl.loc('ProvideExplicitVersion', testPlatformVersion));
}
vstestPlatformInstalledLocation = await new NugetDownloadHelper()
.attemptPackageDownload(packageSource, testPlatformVersion, nugetConfigFilePath);
// Set the vstest platform tool location for the vstest task to consume
helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:92,代码来源:nugetfeedinstaller.ts
注:本文中的azure-pipelines-task-lib/task.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论