From b59a667a4f64c631924aba32dfc63dd024bcaa36 Mon Sep 17 00:00:00 2001 From: Satu Bailey <24945574+satbai@users.noreply.github.com> Date: Mon, 3 Feb 2020 16:26:15 -0800 Subject: [PATCH] Fix instances of JSON.stringify(error) in packaging tasks --- .../artifacts-common/connectionDataUtils.ts | 7 +++- Tasks/Common/artifacts-common/retryUtils.ts | 7 +++- .../resources.resjson/en-US/resources.resjson | 2 +- .../packaging-common/locationUtilities.ts | 9 +++--- Tasks/Common/packaging-common/module.json | 2 +- Tasks/Common/packaging-common/provenance.ts | 4 ++- Tasks/Common/packaging-common/util.ts | 32 +++++++++++++++++-- Tasks/DotNetCoreCLIV2/pushcommand.ts | 4 +-- Tasks/DotNetCoreCLIV2/restorecommand.ts | 4 +-- Tasks/MavenV2/mavenutil.ts | 3 +- Tasks/MavenV3/mavenutil.ts | 3 +- Tasks/NpmAuthenticateV0/npmauth.ts | 6 ++-- Tasks/NpmV0/npmtask.ts | 3 +- Tasks/NpmV1/npm.ts | 2 +- Tasks/NuGetCommandV2/nugetcustom.ts | 3 +- Tasks/NuGetCommandV2/nugetpublisher.ts | 3 +- Tasks/NuGetCommandV2/nugetrestore.ts | 3 +- Tasks/NuGetInstallerV0/nugetinstaller.ts | 3 +- Tasks/NuGetPublisherV0/nugetpublisher.ts | 3 +- Tasks/NuGetRestoreV1/nugetinstaller.ts | 3 +- Tasks/NuGetV0/nuget.ts | 3 +- .../PipAuthenticateV0/pipauthenticatemain.ts | 4 +-- Tasks/TwineAuthenticateV0/authentication.ts | 3 +- Tasks/UniversalPackagesV0/universalpublish.ts | 3 +- 24 files changed, 86 insertions(+), 33 deletions(-) diff --git a/Tasks/Common/artifacts-common/connectionDataUtils.ts b/Tasks/Common/artifacts-common/connectionDataUtils.ts index b83996fb9d8c..875ceb802a0d 100644 --- a/Tasks/Common/artifacts-common/connectionDataUtils.ts +++ b/Tasks/Common/artifacts-common/connectionDataUtils.ts @@ -79,7 +79,12 @@ async function getServiceUriFromAreaId(areaId: string, accessToken: string): Pro return serviceUriFromArea.locationUrl; } catch (error) { tl.debug(`Failed to obtain the service URI for area ID ${areaId}`); - tl.debug(JSON.stringify(error)); + if (error instanceof Error) { + if (error.message) { tl.debug(error.message); } + if (error.stack) { tl.debug(error.stack); } + } else { + tl.debug(error); + } throw error; } } \ No newline at end of file diff --git a/Tasks/Common/artifacts-common/retryUtils.ts b/Tasks/Common/artifacts-common/retryUtils.ts index 32eda0960bf6..d436355b8da3 100644 --- a/Tasks/Common/artifacts-common/retryUtils.ts +++ b/Tasks/Common/artifacts-common/retryUtils.ts @@ -11,7 +11,12 @@ export async function retryOnException(action: () => Promise, maxTries: nu throw error; } tl.debug(`Attempt failed. Number of tries left: ${maxTries}`); - tl.debug(JSON.stringify(error)); + if (error instanceof Error) { + if (error.message) { tl.debug(error.message); } + if (error.stack) { tl.debug(error.stack); } + } else { + tl.debug(error); + } await delay(retryIntervalInMilliseconds); } } diff --git a/Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson index 311b0d1417ac..1da71b1d4feb 100644 --- a/Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson @@ -24,6 +24,6 @@ "loc.messages.NGCommon_SpsNotFound": "Unable to find the '%s' [%s] area. There may be a problem with your Team Foundation Server installation.", "loc.messages.NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.", "loc.messages.NGCommon_UnableToFindTool": "Unable to find tool %s", - "loc.messages.Warning_SessionCreationFailed": "Could not create provenance session: %s", + "loc.messages.Warning_SessionCreationFailed": "Could not create provenance session:", "loc.messages.Warning_UpdatingNuGetVersion": "Updating version of NuGet.exe to %s from %s. Behavior changes or breaking changes might occur as NuGet updates to a new version. If this is not desired, uncheck the 'Check for Latest Version' option in the task." } \ No newline at end of file diff --git a/Tasks/Common/packaging-common/locationUtilities.ts b/Tasks/Common/packaging-common/locationUtilities.ts index c40a7999b644..3b6590a83113 100644 --- a/Tasks/Common/packaging-common/locationUtilities.ts +++ b/Tasks/Common/packaging-common/locationUtilities.ts @@ -4,6 +4,7 @@ import * as tl from 'azure-pipelines-task-lib/task'; import { IRequestOptions } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; import * as provenance from "./provenance"; +import { logError, LogType } from './util'; export enum ProtocolType { NuGet, @@ -146,7 +147,7 @@ export function getWebApiWithProxy(serviceUri: string, accessToken?: string): vs }; const webApi = new vsts.WebApi(serviceUri, credentialHandler, options); tl.debug(`Created webApi client for ${serviceUri}; options: ${JSON.stringify(options)}`); - return webApi + return webApi; } // This function is to apply retries generically for any unreliable network calls @@ -160,7 +161,7 @@ export async function retryOnExceptionHelper(action: () => Promise, maxTri throw error; } tl.debug(`Network call failed. Number of retries left: ${maxTries}`); - if (error) tl.warning(error.toString()); + if (error) { logError(error, LogType.warning); } await delay(retryIntervalInMilliseconds); } } @@ -177,8 +178,8 @@ interface RegistryLocation { }; export async function getFeedRegistryUrl( - packagingUrl: string, - registryType: RegistryType, + packagingUrl: string, + registryType: RegistryType, feedId: string, project: string, accessToken?: string, diff --git a/Tasks/Common/packaging-common/module.json b/Tasks/Common/packaging-common/module.json index f8286e3a7beb..2a8d693ef267 100644 --- a/Tasks/Common/packaging-common/module.json +++ b/Tasks/Common/packaging-common/module.json @@ -25,7 +25,7 @@ "NGCommon_SpsNotFound": "Unable to find the '%s' [%s] area. There may be a problem with your Team Foundation Server installation.", "NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.", "NGCommon_UnableToFindTool": "Unable to find tool %s", - "Warning_SessionCreationFailed": "Could not create provenance session: %s", + "Warning_SessionCreationFailed": "Could not create provenance session:", "Warning_UpdatingNuGetVersion": "Updating version of NuGet.exe to %s from %s. Behavior changes or breaking changes might occur as NuGet updates to a new version. If this is not desired, uncheck the 'Check for Latest Version' option in the task." } } \ No newline at end of file diff --git a/Tasks/Common/packaging-common/provenance.ts b/Tasks/Common/packaging-common/provenance.ts index d2e3032109b4..fe3f4743bade 100644 --- a/Tasks/Common/packaging-common/provenance.ts +++ b/Tasks/Common/packaging-common/provenance.ts @@ -3,6 +3,7 @@ import * as tl from 'azure-pipelines-task-lib'; import * as VsoBaseInterfaces from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; import { ClientVersioningData } from 'azure-devops-node-api/VsoClient'; import vstsClientBases = require('azure-devops-node-api/ClientApiBases'); +import { logError, LogType } from './util'; import * as restclient from 'typed-rest-client/RestClient'; @@ -67,7 +68,8 @@ export class ProvenanceHelper { const session = await prov.createSession(sessionRequest, protocol, project); return session.sessionId; } catch (error) { - tl.warning(tl.loc("Warning_SessionCreationFailed", JSON.stringify(error))); + tl.warning(tl.loc("Warning_SessionCreationFailed")); + logError(error, LogType.warning); } } return feedId; diff --git a/Tasks/Common/packaging-common/util.ts b/Tasks/Common/packaging-common/util.ts index 2cab209fd4ba..8f75be93e54f 100644 --- a/Tasks/Common/packaging-common/util.ts +++ b/Tasks/Common/packaging-common/util.ts @@ -82,8 +82,8 @@ export function getProjectAndFeedIdFromInputParam(inputParam: string): any { } export function getProjectAndFeedIdFromInput(feedProject: string): any { - var projectId = null; - var feedId = feedProject; + let projectId = null; + let feedId = feedProject; if(feedProject && feedProject.includes("/")) { const feedProjectParts = feedProject.split("/"); projectId = feedProjectParts[0] || null; @@ -95,3 +95,31 @@ export function getProjectAndFeedIdFromInput(feedProject: string): any { projectId: projectId } } + +export enum LogType { + debug, + warning, + error +} + +function log(message: string, logType: LogType) { + if (logType === LogType.warning) { + tl.warning(message); + } else if (logType === LogType.error) { + tl.error(message); + } else { + tl.debug(message); + } +} + +/** + * Logs the error instead of throwing. + */ +export function logError(error: any, logType: LogType = LogType.debug) { + if (error instanceof Error) { + if (error.message) { log(error.message, logType); } + if (error.stack) { log(error.stack, LogType.debug); } // Log stack always as debug + } else { + log(`Error: ${error}`, logType); + } +} diff --git a/Tasks/DotNetCoreCLIV2/pushcommand.ts b/Tasks/DotNetCoreCLIV2/pushcommand.ts index 478ce7089a88..09b4d14f4378 100644 --- a/Tasks/DotNetCoreCLIV2/pushcommand.ts +++ b/Tasks/DotNetCoreCLIV2/pushcommand.ts @@ -9,7 +9,7 @@ import { IExecOptions } from 'azure-pipelines-task-lib/toolrunner'; import { NuGetConfigHelper2 } from 'packaging-common/nuget/NuGetConfigHelper2'; import * as ngRunner from 'packaging-common/nuget/NuGetToolRunner2'; import * as pkgLocationUtils from 'packaging-common/locationUtilities'; -import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; +import { getProjectAndFeedIdFromInputParam, logError } from 'packaging-common/util'; export async function run(): Promise { let packagingLocation: pkgLocationUtils.PackagingLocation; @@ -17,7 +17,7 @@ export async function run(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug('Unable to get packaging URIs, using default collection URI'); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri'); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/DotNetCoreCLIV2/restorecommand.ts b/Tasks/DotNetCoreCLIV2/restorecommand.ts index 3889ce3e1099..527df01d77cb 100644 --- a/Tasks/DotNetCoreCLIV2/restorecommand.ts +++ b/Tasks/DotNetCoreCLIV2/restorecommand.ts @@ -9,7 +9,7 @@ import { IExecOptions } from 'azure-pipelines-task-lib/toolrunner'; import * as nutil from 'packaging-common/nuget/Utility'; import * as commandHelper from 'packaging-common/nuget/CommandHelper'; import * as pkgLocationUtils from 'packaging-common/locationUtilities'; -import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; +import { getProjectAndFeedIdFromInputParam, logError } from 'packaging-common/util'; export async function run(): Promise { let packagingLocation: pkgLocationUtils.PackagingLocation; @@ -17,7 +17,7 @@ export async function run(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug('Unable to get packaging URIs, using default collection URI'); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri'); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/MavenV2/mavenutil.ts b/Tasks/MavenV2/mavenutil.ts index 648507603f60..279c7007b5c6 100644 --- a/Tasks/MavenV2/mavenutil.ts +++ b/Tasks/MavenV2/mavenutil.ts @@ -5,6 +5,7 @@ import fs = require('fs'); import * as tl from 'azure-pipelines-task-lib/task'; import * as tr from 'azure-pipelines-task-lib/toolrunner'; import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; import * as url from "url"; import * as xml2js from 'xml2js'; @@ -200,7 +201,7 @@ async function collectFeedRepositories(pomContents:string): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.Maven); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); packagingLocation = { PackagingUris: [collectionUrl], DefaultPackagingUri: collectionUrl diff --git a/Tasks/MavenV3/mavenutil.ts b/Tasks/MavenV3/mavenutil.ts index 935192676319..2e4b60215712 100644 --- a/Tasks/MavenV3/mavenutil.ts +++ b/Tasks/MavenV3/mavenutil.ts @@ -5,6 +5,7 @@ import fs = require('fs'); import * as tl from 'azure-pipelines-task-lib/task'; import * as tr from 'azure-pipelines-task-lib/toolrunner'; import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; import * as url from "url"; import * as xml2js from 'xml2js'; @@ -200,7 +201,7 @@ export async function collectFeedRepositories(pomContents:string): Promise packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.Maven); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); packagingLocation = { PackagingUris: [collectionUrl], DefaultPackagingUri: collectionUrl}; diff --git a/Tasks/NpmAuthenticateV0/npmauth.ts b/Tasks/NpmAuthenticateV0/npmauth.ts index 3080b69eff04..0873fa0eb591 100644 --- a/Tasks/NpmAuthenticateV0/npmauth.ts +++ b/Tasks/NpmAuthenticateV0/npmauth.ts @@ -72,7 +72,7 @@ async function main(): Promise { 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)); + util.logError(error); const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri'); packagingLocation = { PackagingUris: [collectionUrl], @@ -80,14 +80,14 @@ async function main(): Promise { }; } let LocalNpmRegistries = await npmutil.getLocalNpmRegistries(workingDirectory, packagingLocation.PackagingUris); - + let npmrcFile = fs.readFileSync(npmrc, 'utf8').split(os.EOL); for (let RegistryURLString of npmrcparser.GetRegistries(npmrc, /* saveNormalizedRegistries */ true)) { let registryURL = URL.parse(RegistryURLString); let registry: npmregistry.NpmRegistry; if (endpointRegistries && endpointRegistries.length > 0) { for (let serviceEndpoint of endpointRegistries) { - + if (util.toNerfDart(serviceEndpoint.url) == util.toNerfDart(RegistryURLString)) { let serviceURL = URL.parse(serviceEndpoint.url); console.log(tl.loc("AddingEndpointCredentials", registryURL.host)); diff --git a/Tasks/NpmV0/npmtask.ts b/Tasks/NpmV0/npmtask.ts index 848c0febb60e..3c91b2683228 100644 --- a/Tasks/NpmV0/npmtask.ts +++ b/Tasks/NpmV0/npmtask.ts @@ -5,6 +5,7 @@ import tl = require('vsts-task-lib/task'); import trm = require('vsts-task-lib/toolrunner'); var extend = require('util')._extend; import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; interface EnvironmentDictionary { [key: string]: string; } @@ -199,7 +200,7 @@ async function addBuildCredProviderEnv(env: EnvironmentDictionary) : Promise { 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)); + util.logError(error); const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri'); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetCommandV2/nugetcustom.ts b/Tasks/NuGetCommandV2/nugetcustom.ts index 1286a5b9bdef..b92bc0675c2a 100644 --- a/Tasks/NuGetCommandV2/nugetcustom.ts +++ b/Tasks/NuGetCommandV2/nugetcustom.ts @@ -2,6 +2,7 @@ import * as auth from "packaging-common/nuget/Authentication"; import * as ngToolRunner from "packaging-common/nuget/NuGetToolRunner2"; import * as nutil from "packaging-common/nuget/Utility"; import * as tl from "azure-pipelines-task-lib/task"; +import { logError } from 'packaging-common/util'; import peParser = require("packaging-common/pe-parser/index"); import * as pkgLocationUtils from "packaging-common/locationUtilities"; @@ -23,7 +24,7 @@ export async function run(nuGetPath: string): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetCommandV2/nugetpublisher.ts b/Tasks/NuGetCommandV2/nugetpublisher.ts index adcd60d728fb..ae57226f5e0e 100644 --- a/Tasks/NuGetCommandV2/nugetpublisher.ts +++ b/Tasks/NuGetCommandV2/nugetpublisher.ts @@ -14,6 +14,7 @@ import INuGetCommandOptions from "packaging-common/nuget/INuGetCommandOptions2"; import * as vstsNuGetPushToolRunner from "./Common/VstsNuGetPushToolRunner"; import * as vstsNuGetPushToolUtilities from "./Common/VstsNuGetPushToolUtilities"; import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; +import { logError } from 'packaging-common/util'; class PublishOptions implements INuGetCommandOptions { constructor( @@ -41,7 +42,7 @@ export async function run(nuGetPath: string): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetCommandV2/nugetrestore.ts b/Tasks/NuGetCommandV2/nugetrestore.ts index e8b56311ee8d..98412665ec11 100644 --- a/Tasks/NuGetCommandV2/nugetrestore.ts +++ b/Tasks/NuGetCommandV2/nugetrestore.ts @@ -13,6 +13,7 @@ import * as pkgLocationUtils from "packaging-common/locationUtilities"; import * as telemetry from "utility-common/telemetry"; import INuGetCommandOptions from "packaging-common/nuget/INuGetCommandOptions2"; import { getProjectAndFeedIdFromInputParam } from 'packaging-common/util'; +import { logError } from 'packaging-common/util'; class RestoreOptions implements INuGetCommandOptions { constructor( @@ -33,7 +34,7 @@ export async function run(nuGetPath: string): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetInstallerV0/nugetinstaller.ts b/Tasks/NuGetInstallerV0/nugetinstaller.ts index 72a8beb08d76..13f4ee0c1803 100644 --- a/Tasks/NuGetInstallerV0/nugetinstaller.ts +++ b/Tasks/NuGetInstallerV0/nugetinstaller.ts @@ -10,6 +10,7 @@ import * as ngToolGetter from "packaging-common/nuget/NuGetToolGetter"; import * as ngToolRunner from "packaging-common/nuget/NuGetToolRunner"; import * as nutil from "packaging-common/nuget/Utility"; import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; class RestoreOptions implements INuGetCommandOptions { constructor( @@ -29,7 +30,7 @@ async function main(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetPublisherV0/nugetpublisher.ts b/Tasks/NuGetPublisherV0/nugetpublisher.ts index 98ed9825d405..dc97c0735fa1 100644 --- a/Tasks/NuGetPublisherV0/nugetpublisher.ts +++ b/Tasks/NuGetPublisherV0/nugetpublisher.ts @@ -9,6 +9,7 @@ import * as ngToolGetter from "packaging-common/nuget/NuGetToolGetter"; import * as ngToolRunner from "packaging-common/nuget/NuGetToolRunner"; import * as nutil from "packaging-common/nuget/Utility"; import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; class PublishOptions implements INuGetCommandOptions { constructor( @@ -28,7 +29,7 @@ async function main(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetRestoreV1/nugetinstaller.ts b/Tasks/NuGetRestoreV1/nugetinstaller.ts index bb2d3f3fa2d1..68bb1aecc35b 100644 --- a/Tasks/NuGetRestoreV1/nugetinstaller.ts +++ b/Tasks/NuGetRestoreV1/nugetinstaller.ts @@ -13,6 +13,7 @@ import peParser = require('packaging-common/pe-parser/index'); import {VersionInfo} from "packaging-common/pe-parser/VersionResource"; import * as pkgLocationUtils from "packaging-common/locationUtilities"; import { getProjectAndFeedIdFromInputParam } from "packaging-common/util" +import { logError } from 'packaging-common/util'; const NUGET_ORG_V2_URL: string = "https://www.nuget.org/api/v2/"; const NUGET_ORG_V3_URL: string = "https://api.nuget.org/v3/index.json"; @@ -35,7 +36,7 @@ async function main(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/NuGetV0/nuget.ts b/Tasks/NuGetV0/nuget.ts index 597a00a3726e..92b00b95a132 100644 --- a/Tasks/NuGetV0/nuget.ts +++ b/Tasks/NuGetV0/nuget.ts @@ -7,6 +7,7 @@ import * as auth from "packaging-common/nuget/Authentication"; import nuGetGetter = require("packaging-common/nuget/NuGetToolGetter"); import peParser = require('packaging-common/pe-parser/index'); import * as pkgLocationUtils from "packaging-common/locationUtilities"; +import { logError } from 'packaging-common/util'; class NuGetExecutionOptions { constructor( @@ -23,7 +24,7 @@ async function main(): Promise { packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet); } catch (error) { tl.debug("Unable to get packaging URIs, using default collection URI"); - tl.debug(JSON.stringify(error)); + logError(error); const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri"); packagingLocation = { PackagingUris: [collectionUrl], diff --git a/Tasks/PipAuthenticateV0/pipauthenticatemain.ts b/Tasks/PipAuthenticateV0/pipauthenticatemain.ts index 1836d3e6158c..5b943d8fe083 100644 --- a/Tasks/PipAuthenticateV0/pipauthenticatemain.ts +++ b/Tasks/PipAuthenticateV0/pipauthenticatemain.ts @@ -4,7 +4,7 @@ import * as pkgLocationUtils from "packaging-common/locationUtilities"; import * as telemetry from "utility-common/telemetry"; import * as auth from "./authentication"; import * as utils from "./utilities"; -import { getProjectAndFeedIdFromInput } from 'packaging-common/util'; +import { getProjectAndFeedIdFromInput, logError } from 'packaging-common/util'; async function main(): Promise { tl.setResourcePath(path.join(__dirname, "task.json")); @@ -32,7 +32,7 @@ async function main(): Promise { localAccessToken); } catch (error) { tl.debug(tl.loc("FailedToGetPackagingUri")); - tl.debug(JSON.stringify(error)); + logError(error); packagingLocation = serviceUri; } diff --git a/Tasks/TwineAuthenticateV0/authentication.ts b/Tasks/TwineAuthenticateV0/authentication.ts index f86d8815e952..fa324123eb12 100644 --- a/Tasks/TwineAuthenticateV0/authentication.ts +++ b/Tasks/TwineAuthenticateV0/authentication.ts @@ -1,6 +1,7 @@ import * as tl from "azure-pipelines-task-lib/task"; import * as pkgLocationUtils from "packaging-common/locationUtilities"; import { getProjectAndFeedIdFromInput } from 'packaging-common/util'; +import { logError } from 'packaging-common/util'; export interface IPackageSource { feedUri: string; @@ -50,7 +51,7 @@ export async function getInternalAuthInfoArray(inputKey: string): Promise { const buildIdentityDisplayName: string = null; @@ -69,7 +70,7 @@ export async function run(artifactToolPath: string): Promise { serviceUri, accessToken); } catch (error) { - tl.debug(JSON.stringify(error)); + logError(error); packagingLocation = serviceUri; }