Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions images/windows/scripts/build/Install-MongoDB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
$toolsetContent = Get-ToolsetContent
$toolsetVersion = $toolsetContent.mongodb.version

$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/v$toolsetVersion/release-notes/$toolsetVersion/" -UseBasicParsing
$targetReleases = $getMongoReleases.Links.href | Where-Object { $_ -like "#$toolsetVersion*---*" }

$minorVersions = @()
foreach ($release in $targetReleases) {
if ($release -notlike "*upcoming*") {
$pattern = '\d+\.\d+\.\d+'
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
$minorVersions += $version
}
# Resolve the latest patch release from the downloads feed rather than the release notes
# page. The feed lists the newest release of each supported branch and is not subject to the
# markup and URL changes that repeatedly broke scraping the docs.
$mongoReleasesUrl = "https://downloads.mongodb.org/current.json"
$mongoReleases = Invoke-RestMethod -Uri $mongoReleasesUrl

$latestVersion = $mongoReleases.versions.version |
Where-Object { $_ -like "$toolsetVersion.*" } |
Sort-Object { [version]$_ } -Descending |
Select-Object -First 1

if (-not $latestVersion) {
throw "Unable to resolve latest MongoDB $toolsetVersion release from $mongoReleasesUrl"
}

$latestVersion = $minorVersions[0]

Install-Binary `
-Url "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$latestVersion-signed.msi" `
-ExtraInstallArgs @('TARGETDIR=C:\PROGRA~1\MongoDB ADDLOCAL=ALL') `
Expand Down
Loading