本文整理汇总了TypeScript中azure-pipelines-task-lib.debug函数的典型用法代码示例。如果您正苦于以下问题:TypeScript debug函数的具体用法?TypeScript debug怎么用?TypeScript debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getArtifactToolFromService
export async function getArtifactToolFromService(serviceUri: string, accessToken: string, toolName: string){
const overrideArtifactToolPath = tl.getVariable("UPack.OverrideArtifactToolPath");
if (overrideArtifactToolPath != null) {
return getArtifactToolLocation(overrideArtifactToolPath);
}
let osName = tl.osType();
let arch = os.arch();
if (osName === "Windows_NT"){
osName = "windows";
}
if (arch === "x64"){
arch = "amd64";
}
// https://github.com/nodejs/node-v0.x-archive/issues/2862
if (arch === "ia32") {
if (process.env.PROCESSOR_ARCHITEW6432 != null && process.env.PROCESSOR_ARCHITEW6432.toUpperCase() === "AMD64") {
arch = "amd64";
}
}
if (arch.toLowerCase() !== "amd64") {
throw new Error(tl.loc("Error_ProcessorArchitectureNotSupported"));
}
const blobstoreAreaName = "clienttools";
const blobstoreAreaId = "187ec90d-dd1e-4ec6-8c57-937d979261e5";
const ApiVersion = "5.0-preview";
const blobstoreConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);
const artifactToolGetUrl = await pkgLocationUtils.Retry(async () => {
return await blobstoreConnection.vsoClient.getVersioningData(ApiVersion,
blobstoreAreaName, blobstoreAreaId, { toolName }, {osName, arch});
}, 4, 100);
const artifactToolUri = await blobstoreConnection.rest.get(artifactToolGetUrl.requestUrl);
if (artifactToolUri.statusCode !== 200) {
tl.debug(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolUri.result.toString()));
throw new Error(tl.loc("Error_UnexpectedErrorFailedToGetToolMetadata", artifactToolGetUrl.requestUrl));
}
let artifactToolPath = toollib.findLocalTool(toolName, artifactToolUri.result['version']);
if (!artifactToolPath) {
tl.debug(tl.loc("Info_DownloadingArtifactTool", artifactToolUri.result['uri']));
const zippedToolsDir: string = await toollib.downloadTool(artifactToolUri.result['uri']);
tl.debug("Downloaded zipped artifact tool to " + zippedToolsDir);
const unzippedToolsDir = await extractZip(zippedToolsDir);
artifactToolPath = await toollib.cacheDir(unzippedToolsDir, "ArtifactTool", artifactToolUri.result['version']);
} else {
tl.debug(tl.loc("Info_ResolvedToolFromCache", artifactToolPath));
}
return getArtifactToolLocation(artifactToolPath);
}
示例2: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, "task.json"));
try {
// Local feeds
const internalFeeds = await auth.getInternalAuthInfoArray("feedList");
// external service endpoints
const externalEndpoints = await auth.getExternalAuthInfoArray("externalSources");
// combination of both internal and external
const newEndpointsToAdd = internalFeeds.concat(externalEndpoints);
let pypircPath = utils.getPypircPath();
// Case when there are multiple twine auth tasks in a build
if (tl.exist(pypircPath)) {
// merge two tasks
tl.debug(tl.loc("Info_StartParsingExistingPypircFile", pypircPath));
let fileContent = ini.parse(fs.readFileSync(pypircPath, "utf-8"));
// Adding new endpoints to already existing .pypirc file.
for (const entry of newEndpointsToAdd){
if (entry.packageSource.feedName in fileContent){
// Hard fail if there is a name collision from service endpoint
throw new Error(tl.loc("Error_DuplicateEntryForExternalFeed",
entry.packageSource.feedName));
}
fileContent[entry.packageSource.feedName] = new Repository(
entry.packageSource.feedUri,
entry.username,
entry.password);
fileContent["distutils"]["index-servers"] += " " + entry.packageSource.feedName;
}
let encodedStr = ini.encode(fileContent);
fs.writeFileSync(pypircPath, encodedStr);
}
else {
// create new
fs.writeFileSync(pypircPath, formPypircFormatFromData(newEndpointsToAdd));
tl.setVariable("PYPIRC_PATH", pypircPath, false);
tl.debug(tl.loc("VariableSetForPypirc", pypircPath));
}
// Configuring the pypirc file
console.log(tl.loc("Info_SuccessAddingAuth", internalFeeds.length, externalEndpoints.length));
}
catch (error) {
tl.error(error);
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToAddAuthentication"));
return;
} finally{
_logTwineAuthStartupVariables();
}
}
示例3: _logUniversalStartupVariables
function _logUniversalStartupVariables(params: any) {
try {
telemetry.emitTelemetry("Packaging", "DownloadPackagev1", params);
} catch (err) {
tl.debug(`Unable to log Universal Packages task init telemetry. Err:( ${err} )`);
}
}
示例4: GetSessionId
public static async GetSessionId(
feedId: string,
project: string,
protocol: string,
baseUrl: string,
handlers: VsoBaseInterfaces.IRequestHandler[],
options: VsoBaseInterfaces.IRequestOptions): Promise<string> {
const publishPackageMetadata = tl.getInput("publishPackageMetadata");
let shouldCreateSession = publishPackageMetadata && publishPackageMetadata.toLowerCase() == 'true';
if (shouldCreateSession) {
const useSessionEnabled = tl.getVariable("Packaging.SavePublishMetadata");
shouldCreateSession = shouldCreateSession && !(useSessionEnabled && useSessionEnabled.toLowerCase() == 'false')
}
if (shouldCreateSession) {
tl.debug("Creating provenance session to save pipeline metadata. This can be disabled in the task settings, or by setting build variable Packaging.SavePublishMetadata to false");
const prov = new ProvenanceApi(baseUrl, handlers, options);
const sessionRequest = ProvenanceHelper.CreateSessionRequest(feedId);
try {
const session = await prov.createSession(sessionRequest, protocol, project);
return session.sessionId;
} catch (error) {
tl.warning(tl.loc("Warning_SessionCreationFailed", JSON.stringify(error)));
}
}
return feedId;
}
示例5: _logTwineAuthStartupVariables
// Telemetry
function _logTwineAuthStartupVariables() {
try {
const twineAuthenticateTelemetry = {
"System.TeamFoundationCollectionUri": tl.getVariable("System.TeamFoundationCollectionUri"),
};
telemetry.emitTelemetry("Packaging", "TwineAuthenticate", twineAuthenticateTelemetry);
} catch (err) {
tl.debug(`Unable to log Twine Authenticate task init telemetry. Err:( ${err} )`);
}
}
示例6: downloadUniversalPackage
export async function downloadUniversalPackage(
downloadPath: string,
feedId: string,
packageId: string,
version: string,
filterPattern: string
): Promise<void> {
try {
const accessToken = pkgLocationUtils.getSystemAccessToken();
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
const blobUri = await pkgLocationUtils.getBlobstoreUriFromBaseServiceUri(serviceUri, accessToken);
// Finding the artifact tool directory
var artifactToolPath = await artifactToolUtilities.getArtifactToolFromService(
blobUri,
accessToken,
"artifacttool"
);
const feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
let packageName: string = await artifactToolUtilities.getPackageNameFromId(
feedUri,
accessToken,
feedId,
packageId
);
tl.debug(tl.loc("Info_UsingArtifactToolDownload"));
const downloadOptions = {
artifactToolPath,
feedId,
accountUrl: serviceUri,
packageName,
packageVersion: version
} as artifactToolRunner.IArtifactToolOptions;
let toolRunnerOptions = artifactToolRunner.getOptions();
toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = accessToken;
downloadPackageUsingArtifactTool(downloadPath, downloadOptions, toolRunnerOptions, filterPattern);
} catch (error) {
tl.setResult(tl.TaskResult.Failed, error.message);
return;
} finally {
_logUniversalStartupVariables({
ArtifactToolPath: artifactToolPath,
PackageType: "Universal",
FeedId : feedId,
PackageId: packageId,
Version: version,
IsTriggeringArtifact: tl.getInput("isTriggeringArtifact")
});
}
}
示例7: _logUniversalStartupVariables
function _logUniversalStartupVariables(artifactToolPath: string) {
try {
let universalPackagesTelemetry = {
"command": tl.getInput("command"),
"buildProperties": tl.getInput("buildProperties"),
"basePath": tl.getInput("basePath"),
"System.TeamFoundationCollectionUri": tl.getVariable("System.TeamFoundationCollectionUri"),
"verbosity": tl.getInput("verbosity"),
"solution": tl.getInput("solution"),
"artifactToolPath": artifactToolPath,
};
telemetry.emitTelemetry("Packaging", "UniversalPackages", universalPackagesTelemetry);
} catch (err) {
tl.debug(`Unable to log Universal Packages task init telemetry. Err:( ${err} )`);
}
}
示例8: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, "task.json"));
// Getting artifact tool
tl.debug("Getting artifact tool");
let artifactToolPath: string;
try {
const serverType = tl.getVariable("System.ServerType");
if (!serverType || serverType.toLowerCase() !== "hosted"){
throw new Error(tl.loc("Error_UniversalPackagesNotSupportedOnPrem"));
}
const localAccessToken = pkgLocationUtils.getSystemAccessToken();
const serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
const blobUri = await pkgLocationUtils.getBlobstoreUriFromBaseServiceUri(
serviceUri,
localAccessToken);
// Finding the artifact tool directory
artifactToolPath = await artifactToolUtilities.getArtifactToolFromService(
blobUri,
localAccessToken,
"artifacttool");
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, tl.loc("FailedToGetArtifactTool", error.message));
return;
} finally{
_logUniversalStartupVariables(artifactToolPath);
}
// Calling the command. download/publish
const universalPackageCommand = tl.getInput("command", true);
switch (universalPackageCommand) {
case "download":
universalDownload.run(artifactToolPath);
break;
case "publish":
universalPublish.run(artifactToolPath);
break;
default:
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_CommandNotRecognized", universalPackageCommand));
break;
}
}
示例9: getVsixPublisherExe
export function getVsixPublisherExe(): string {
if (cacheVsixPublisherExe === "") {
const vswhereTool = tl.tool(path.join(__dirname, "tools", "vswhere.exe"));
vswhereTool.line("-version [15.0,17.0) -latest -requires Microsoft.VisualStudio.Component.VSSDK -find VSSDK\\VisualStudioIntegration\\Tools\\Bin\\VsixPublisher.exe");
const vswhereResult = vswhereTool.execSync({ silent: true } as tr.IExecSyncOptions);
const vsixPublisherExe = vswhereResult.stdout.trim();
if (vswhereResult.code === 0 && vsixPublisherExe && tl.exist(vsixPublisherExe))
{
tl.debug('VsixPublisher.exe installed path: ' + vsixPublisherExe);
cacheVsixPublisherExe = vsixPublisherExe;
}
else
{
throw new Error("Could not locate vsixpublisher.exe. Ensure the Visual Studio SDK is installed on the agent.");
}
}
return cacheVsixPublisherExe;
}
示例10: async
var progressLogger = async () => setTimeout(() => {
var tickets = this.store.getTickets();
var queuedItems = tickets.filter(x => x.state == TicketState.InQueue);
var processingItems = tickets.filter(x => x.state == TicketState.Processing);
var processedItems = tickets.filter(x => x.state == TicketState.Processed);
var skippedItems = tickets.filter(x => x.state == TicketState.Skipped);
var failedItems = tickets.filter(x => x.state == TicketState.Failed);
var currentTime = new Date();
tl.debug(
"Total Items: " + tickets.length
+ ", Processed: " + processedItems.length
+ ", Processing: " + processingItems.length
+ ", Queued: " + queuedItems.length
+ ", Skipped: " + skippedItems.length
+ ", Failed: " + failedItems.length
+ ", Time elapsed: " + ((currentTime.valueOf() - this.startTime.valueOf()) / 1000) + "secs");
if (this.store.itemsPendingProcessing() && !this.store.hasDownloadFailed()) {
progressLogger();
}
}, 5000);