nomad icon indicating copy to clipboard operation
nomad copied to clipboard

artifact: turn on windows git artifact downloader e2e test case

Open shoenig opened this issue 2 years ago • 1 comments
trafficstars

The e2e test case for downloading an artifact via Git on Windows is currently commented out, because our Packer image for Windows does not install Git. I got this to work on Windows 2022 by installing git via winget (i.e. get git via winget Git.Git, get it?). However our packer image uses Windows 2016 and we'll have to install git by some other method.

https://github.com/hashicorp/nomad/blob/main/e2e/artifact/input/artifact_windows.nomad#L77

shoenig avatar Dec 08 '22 18:12 shoenig

I just scripted an unattended install of Git for some servers, and while I can't share the script I can suggest the basics.

You can download the git installer from https://github.com/git-for-windows/git/releases/download/v$($Version).windows.1/Git-$($Version)-64-bit.exe . It would be good to very the SHA256 matches an expected value if possible.

You can configure the install using an config file - I pull it from a GitLab repo using their REST API, but it could be a template.

[Setup]
Lang=default
Dir=C:\Program Files\Git
Group=Git
NoIcons=0
SetupType=default
Components=gitlfs,assoc
Tasks=
EditorOption=Notepad
DefaultBranchOption=main
CURLOption=WinSSL
UseCredentialManager=Enabled
SSHOption=ExternalOpenSSH

And then you just call the installer with the /LOADINF and /VERYSILENT flags. You can watch the log file to determine when the install is complete. You may be able to have it forcefully reboot when complete, I'm not sure.

$Version = "2.47.0"
$OutputFile= "Git-$($Version)-64-bit.exe"
 $dlSplat = @{
    Uri     = "https://github.com/git-for-windows/git/releases/download/v$($Version).windows.1/Git-$($Version)-64-bit.exe"
    OutFile = $OutputFile
  }
Invoke-RestMethod @dlSplat -ErrorAction 'stop' 
& $OutputFile "/VERYSILENT" "/NORESTART" "/NOCANCEL" "/LOADINF=$InstallSettingsPath" "/LOG=$LogFile"

NucaChance avatar Oct 22 '24 16:10 NucaChance