Skip to content

Commit

Permalink
Merge pull request #503 from jenkinsci/lemeurherve-patch-1
Browse files Browse the repository at this point in the history
fix(windows) bump `git-lfs` to 3.4.0 and fix its installation
  • Loading branch information
dduportal authored Sep 14, 2023
2 parents aa99a7f + 27f27b1 commit a9f43c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
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 ; `
$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

0 comments on commit a9f43c0

Please sign in to comment.