I want to create a build job for one of our java projects on our Jenkins. The pipeline is a multi-branch pipeline and unfortunately it is not possible to install git-lfs on our Jenkins-slaves to I cannot use the additional step form the multi-branch pipeline to perform git lfs pull. So I created a Dockerfile where I extended an base image to contain git-lfs
FROM eclipse-temurin:21.0.4_7-jdk-alpine
RUN apk update && apk add --no-cache git git-lfs && git lfs install
Then I use this image in my Jenkinsfile:
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
additionalBuildArgs '--tag westranger-custom-jdk-21-lts:20240924'
label 'linux'
}
}
stages {
stage('Checkout LFS') {
steps {
withCredentials([usernamePassword(credentialsId: 'westranger',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD')]) {
sh "git lfs install --local --skip-repo"
sh "git lfs pull"
}
}
}
stage('Build') {
steps {
sh './mvnw clean install -DskipTests'
}
}
stage('Test') {
steps {
sh './mvnw test jacoco:report'
}
}
}
}
And when executing the job on the jenkins I get the following error:
[Pipeline] {
[Pipeline] stage (hide)
[Pipeline] { (Checkout LFS)
[Pipeline] withCredentials
Masking supported pattern matches of $USERNAME or $PASSWORD
[Pipeline] {
[Pipeline] sh
+ git lfs install --local --skip-repo
Git LFS initialized.
[Pipeline] sh
+ git lfs pull
batch request: executable file not found in $PATH
batch request: executable file not found in $PATH
batch request: executable file not found in $PATH
Failed to fetch some objects from 'https://bitbucket.org/westranger/my-java-project.git/info/lfs'
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage "Build" skipped due to earlier failure(s)
I tried to find solutions on the web so far but without any luck. The $PATH made me think that maybe git lfs is not properly installed but I got this output when asking git for a version
+ git lfs version
git-lfs/3.5.1 (GitHub; linux amd64; go 1.22.5; git v3.5.1)
I mean I cannot be the first one trying this but I found not tutorials on this so far.
To wrap it up: git lfs pull does not work inside of a docker container which is run by a jenkins