Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows) bump git-lfs to 3.4.0 and fix its installation #503

Merged
merged 15 commits into from
Sep 14, 2023
Merged
8 changes: 8 additions & 0 deletions tests/agent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 10 additions & 0 deletions updatecli/updatecli.d/git-lfs-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 10 additions & 7 deletions windows/nanoserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ; `
lemeurherve marked this conversation as resolved.
Show resolved Hide resolved
$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

Expand Down
16 changes: 10 additions & 6 deletions windows/windowsservercore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down