Skip to content

Commit

Permalink
Use pre-release Packer for Windows on Hyper-V
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Finkelshteyn committed Sep 26, 2019
1 parent 3b8fb24 commit ef1e613
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions AppVeyorBYOC-Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ function ValidateDependencies ($cloudType) {
}
}

function GetPackerPath {
$packerVersion = "1.4.3"
function GetPackerPath ([switch]$prerelease) {
$packerVersion = if ($prerelease) {"1.4.4"} else {"1.4.3"}
Write-host "`nChecking if Hashicorp Packer version $packerVersion is installed..." -ForegroundColor Cyan
if ((Get-Command packer -ErrorAction Ignore) -and (packer --version) -eq $packerVersion) {
Write-Host "Packer version $packerVersion found" -ForegroundColor DarkGray
Expand All @@ -252,7 +252,8 @@ function GetPackerPath {
$currentSecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol
$zipFile = if ($isLinux) {"packer_$($packerVersion)_linux_amd64.zip"} elseif ($isMacOS) {"packer_$($packerVersion)_darwin_amd64.zip"} else {"packer_$($packerVersion)_windows_amd64.zip"}
[System.Net.ServicePointManager]::SecurityProtocol = "Tls12"
(New-Object Net.WebClient).DownloadFile("https://releases.hashicorp.com/packer/$packerVersion/$zipFile", $zipPath)
$URL = if ($prerelease) {"https://github.com/appveyor/build-images/releases/download/packer-1.4.4/packer_windows_amd64.zip"} else {"https://releases.hashicorp.com/packer/$packerVersion/$zipFile"}
(New-Object Net.WebClient).DownloadFile($URL, $zipPath)
[System.Net.ServicePointManager]::SecurityProtocol = $currentSecurityProtocol
Expand-Archive -LiteralPath $zipPath -DestinationPath $packerFolder
Remove-Item $zipPath -force -ErrorAction Ignore
Expand Down
2 changes: 1 addition & 1 deletion Connect-AppVeyorToHyperV.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ d-i passwd/user-default-groups appveyor sudo

#Run Packer to create an VHD
if (-not $VhdPath) {
$packerPath = GetPackerPath
$packerPath = if ($imageOs -eq "Windows") {$(GetPackerPath -prerelease)} else {$(GetPackerPath)}
$packerManifest = "$(CreateTempFolder)/packer-manifest.json"
Write-host "`nRunning Packer to create a basic build VM VHD..." -ForegroundColor Cyan
Write-Warning "Add '-VhdPath' parameter with if you want to to skip Packer build and and reuse existing VHD."
Expand Down

0 comments on commit ef1e613

Please sign in to comment.