diff --git a/tests/agent.Tests.ps1 b/tests/agent.Tests.ps1 index 876d27780..1ad799e1a 100644 --- a/tests/agent.Tests.ps1 +++ b/tests/agent.Tests.ps1 @@ -23,6 +23,8 @@ if($global:WINDOWSFLAVOR -eq 'nanoserver') { $global:CONTAINERSHELL = "pwsh.exe" } +$global:GITLFSVERSION = '3.4.0' + Cleanup($global:CONTAINERNAME) Describe "[$global:AGENT_IMAGE] image is present" { @@ -70,6 +72,12 @@ Describe "[$global:AGENT_IMAGE] image has correct applications in the PATH" { $stdout.Trim() | Should -Match "user.*jenkins" } + It 'has git-lfs (and thus git) installed' { + $exitCode, $stdout, $stderr = Run-Program 'docker' "exec $global:CONTAINERNAME $global:CONTAINERSHELL -C `"`& git lfs version`"" + $exitCode | Should -Be 0 + $stdout.Trim() | Should -Match "git-lfs/${global:GITLFSVERSION}" + } + AfterAll { Cleanup($global:CONTAINERNAME) } diff --git a/updatecli/updatecli.d/git-lfs-windows.yaml b/updatecli/updatecli.d/git-lfs-windows.yaml index 65cae25d7..ce1fc83b5 100644 --- a/updatecli/updatecli.d/git-lfs-windows.yaml +++ b/updatecli/updatecli.d/git-lfs-windows.yaml @@ -45,6 +45,16 @@ targets: keyword: ARG matcher: GIT_LFS_VERSION scmid: default + setGitLfsVersionTests: + name: Update the `git-lfs` Windows version in tests + kind: file + spec: + file: tests/agent.Tests.ps1 + matchpattern: > + global:GIT_LFS_VERSION = '(.*)'$ + replacepattern: > + global:GIT_LFS_VERSION = '{{ source "lastVersion" }}' + scmid: default actions: default: diff --git a/windows/nanoserver/Dockerfile b/windows/nanoserver/Dockerfile index 59a78c852..e7e610ac8 100644 --- a/windows/nanoserver/Dockerfile +++ b/windows/nanoserver/Dockerfile @@ -55,19 +55,22 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl Expand-Archive mingit.zip -DestinationPath c:\mingit ; ` Remove-Item mingit.zip -Force -ARG GIT_LFS_VERSION=3.1.4 +ENV ProgramFiles="C:\Program Files" ` + WindowsPATH="C:\Windows\system32;C:\Windows" ` + JAVA_HOME="${JAVA_HOME}" +ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;C:\mingit\cmd" + +ARG GIT_LFS_VERSION=3.4.0 RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` $url = $('https://github.com/git-lfs/git-lfs/releases/download/v{0}/git-lfs-windows-amd64-v{0}.zip' -f $env:GIT_LFS_VERSION) ; ` Write-Host "Retrieving $url..." ; ` Invoke-WebRequest $url -OutFile 'GitLfs.zip' -UseBasicParsing ; ` Expand-Archive GitLfs.zip -DestinationPath c:\mingit\mingw64\bin ; ` + $gitLfsFolder = 'c:\mingit\mingw64\bin\git-lfs-{0}' -f $env:GIT_LFS_VERSION ; ` + Move-Item -Path "${gitLfsFolder}\git-lfs.exe" -Destination c:\mingit\mingw64\bin\ ; ` + Remove-Item -Path $gitLfsFolder -Recurse -Force ; ` Remove-Item GitLfs.zip -Force ; ` - & C:\mingit\cmd\git.exe lfs install - -ENV ProgramFiles="C:\Program Files" ` - WindowsPATH="C:\Windows\system32;C:\Windows" ` - JAVA_HOME="${JAVA_HOME}" -ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;C:\mingit\cmd" + & c:\mingit\mingw64\bin\git-lfs.exe install ARG user=jenkins diff --git a/windows/windowsservercore/Dockerfile b/windows/windowsservercore/Dockerfile index 29c16e408..9174920ac 100644 --- a/windows/windowsservercore/Dockerfile +++ b/windows/windowsservercore/Dockerfile @@ -47,18 +47,22 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl Expand-Archive mingit.zip -DestinationPath c:\mingit ; ` Remove-Item mingit.zip -Force -ARG GIT_LFS_VERSION=3.1.4 +# Add git and java in PATH +RUN $CurrentPath = (Get-Itemproperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path).Path ; ` + $NewPath = $CurrentPath + $(';{0}\bin;C:\mingit\cmd' -f $env:JAVA_HOME) ; ` + Set-ItemProperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path -Value $NewPath + +ARG GIT_LFS_VERSION=3.4.0 RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` $url = $('https://github.com/git-lfs/git-lfs/releases/download/v{0}/git-lfs-windows-amd64-v{0}.zip' -f $env:GIT_LFS_VERSION) ; ` Write-Host "Retrieving $url..." ; ` Invoke-WebRequest $url -OutFile 'GitLfs.zip' -UseBasicParsing ; ` Expand-Archive GitLfs.zip -DestinationPath c:\mingit\mingw64\bin ; ` + $gitLfsFolder = 'c:\mingit\mingw64\bin\git-lfs-{0}' -f $env:GIT_LFS_VERSION ; ` + Move-Item -Path "${gitLfsFolder}\git-lfs.exe" -Destination c:\mingit\mingw64\bin\ ; ` + Remove-Item -Path $gitLfsFolder -Recurse -Force ; ` Remove-Item GitLfs.zip -Force ; ` - & C:\mingit\cmd\git.exe lfs install ; ` - $CurrentPath = (Get-Itemproperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path).Path ; ` - # Add git and java in PATH - $NewPath = $CurrentPath + $(';{0}\bin;C:\mingit\cmd' -f $env:JAVA_HOME) ; ` - Set-ItemProperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path -Value $NewPath + & c:\mingit\mingw64\bin\git-lfs.exe install ARG user=jenkins