Browse Source

Remove Discord webhook notification logic from NuGet package push scripts. Simplified error handling by exiting with a status code on failures without sending notifications.

pull/25246/head
selmankoc 3 weeks ago
parent
commit
e8320a524a
  1. 29
      nupkg/push-nightly-packages-myget.ps1
  2. 22
      nupkg/push_packages.ps1

29
nupkg/push-nightly-packages-myget.ps1

@ -1,7 +1,6 @@
param(
[string]$source,
[string]$apikey,
[string]$discordWebhookUrl
[string]$apikey
)
if (!$source)
@ -14,11 +13,6 @@ if (!$apikey)
$apikey = "dummy"
}
if (!$discordWebhookUrl)
{
$discordWebhookUrl = $env:DISCORD_WEBHOOK_URL
}
$maxRetryCount = 3
$retryDelaysInSeconds = @(30, 60, 120)
$failedPackages = @()
@ -67,26 +61,5 @@ if ($failedPackages.Count -gt 0)
{
$errorCount = $failedPackages.Count
Write-Host ("******* $errorCount error(s) occured *******") -ForegroundColor red
if (-not [string]::IsNullOrWhiteSpace($discordWebhookUrl))
{
try
{
$messageLines = @(
"Nightly NuGet push completed with failures (ABP).",
"Failed package count: $errorCount",
"Failed packages:"
) + ($failedPackages | ForEach-Object { "- $_" })
$payload = @{ content = ($messageLines -join "`n") } | ConvertTo-Json -Compress
Invoke-RestMethod -Uri $discordWebhookUrl -Method Post -ContentType "application/json" -Body $payload | Out-Null
Write-Host "Discord notification sent for failed packages."
}
catch
{
Write-Warning "Failed to send Discord webhook notification: $($_.Exception.Message)"
}
}
exit 1
}

22
nupkg/push_packages.ps1

@ -1,7 +1,6 @@
. ".\common.ps1"
$apiKey = $args[0]
$discordWebhookUrl = if ($args.Length -gt 1) { $args[1] } else { $env:DISCORD_WEBHOOK_URL }
# Get the version
[xml]$commonPropsXml = Get-Content (Join-Path $rootFolder "common.props")
@ -77,24 +76,5 @@ foreach($project in $projects) {
if ($errorCount > 0)
{
Write-Host ("******* $errorCount error(s) occured *******") -ForegroundColor red
if (-not [string]::IsNullOrWhiteSpace($discordWebhookUrl))
{
try
{
$messageLines = @(
"NuGet push completed with failures (ABP).",
"Failed package count: $errorCount",
"Failed packages:"
) + ($failedPackages | ForEach-Object { "- $_" })
$payload = @{ content = ($messageLines -join "`n") } | ConvertTo-Json -Compress
Invoke-RestMethod -Uri $discordWebhookUrl -Method Post -ContentType "application/json" -Body $payload | Out-Null
Write-Info "Discord notification sent for failed packages."
}
catch
{
Write-Warning "Failed to send Discord webhook notification: $($_.Exception.Message)"
}
}
exit 1
}

Loading…
Cancel
Save