You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seen a request for PostgreSQL to be included with Evergreen (aaronparker/evergreen#747), but Aaron has been unable to find a source, so I have quickly knocked up this script which queries the downloads page: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
It's not the best code I'll admit (partly due to the webpage layout)- But I'm sure with time it could be improved!
# Get-PostgreSQL.ps1
$AppName = "PostgreSQL"
# Define the URL of the PostgreSQL Downloads page
$Releaseurl = "https://www.enterprisedb.com/downloads/postgres-postgresql-downloads"
Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n"
# Use Invoke-WebRequest to get the HTML content
$response = Invoke-WebRequest -Uri $Releaseurl
# Load the HTML content
$htmlContent = $response.Content
# Use regex to extract the links for Windows x86-64 and x86-32
$pattern = '<tr.*?>.*?<td.*?>(.*?)<\/td>.*?<td.*?>(.*?)<\/td>.*?<td.*?>(.*?)<\/td>.*?<td.*?>(.*?)<\/td>.*?<td.*?>(.*?)<\/td>.*?<td.*?>(.*?)<\/td>.*?<\/tr>'
$patternmatches = [regex]::Matches($htmlContent, $pattern)
# Initialize an array to hold the links
$links = @()
# Loop through each match
foreach ($match in $patternmatches) {
# Extract the PostgreSQL Version from table (in case version can not be obtained from URL)
$PostgreSQLVersion = $match.Groups[1].Value
# Extract the href links for Windows x86-64 and x86-32
$x64Link = $match.Groups[5].Value -replace '.*?href="(.*?)".*', '$1'
$x32Link = $match.Groups[6].Value -replace '.*?href="(.*?)".*', '$1'
# Add the links to the array if they exist
if ($x64Link) {
$Arch = "x64"
$SearchCount = 1 # This may need increasing as future versions are released
if ($x64Link -like "*getfile.jsp?fileid=*"){
$URL = (Resolve-Uri -Uri $x64Link).Uri
$Version = Get-Version -String $URL -ReplaceWithDot
} elseif ($x64Link -like "/postgres-postgresql-downloads"){
$URL = Set-UriPrefix -Uri $x64Link -Prefix 'https://www.enterprisedb.com'
} else {
$URL = $x64Link
$Version = Get-Version -String $URL -ReplaceWithDot
}
if ($null -eq $Version) {
$Version = $PostgreSQLVersion
}
Write-Verbose "Version $($Version) 64-bit download: $($x64Link)"
do {
if ($URL) {
New-NevergreenApp -Name $($AppName) -Architecture $($Arch) -Version $Version -Uri $($URL) -Type "exe"
break
}
$SearchCount--
} until ($SearchCount -eq 0)
if ($SearchCount -eq 0) {
Write-Warning "Could not find release for $($AppName) $($Version) $($Arch)"
}
}
$URL = $null
$Version = $null
$Arch = $null
if ($x32Link) {
$Arch = "x86"
$SearchCount = 1 # This may need increasing as future versions are released
if ($x32Link -ne "<span>Not supported</span>"){
if ($x32Link -like "*getfile.jsp?fileid=*"){
$URL = (Resolve-Uri -Uri $x32Link).Uri
$Version = Get-Version -String $URL -ReplaceWithDot
} elseif ($x32Link -like "/postgres-postgresql-downloads"){
$URL = Set-UriPrefix -Uri $x32Link -Prefix 'https://www.enterprisedb.com'
} else {
$URL = $x32Link
$Version = Get-Version -String $URL -ReplaceWithDot
}
}
if ($null -eq $Version) {
$Version = $PostgreSQLVersion
}
Write-Verbose "Version $($Version) 32-bit download: $($x32Link)"
do {
if ($URL) {
New-NevergreenApp -Name $($AppName) -Architecture $($Arch) -Version $($Version) -Uri $($URL) -Type "exe"
break
}
$SearchCount--
} until ($SearchCount -eq 0)
if ($SearchCount -eq 0) {
Write-Warning "Could not find release for $($AppName) $($Version) $($Arch)"
}
}
$URL = $null
$Version = $null
$Arch = $null
}
The text was updated successfully, but these errors were encountered:
Seen a request for PostgreSQL to be included with Evergreen (aaronparker/evergreen#747), but Aaron has been unable to find a source, so I have quickly knocked up this script which queries the downloads page: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
It's not the best code I'll admit (partly due to the webpage layout)- But I'm sure with time it could be improved!
The text was updated successfully, but these errors were encountered: