I have an issue with git LFS use in Jenkins. What I am doing now is that
We have used git plugin and git-client plugin with version 3.3.0 and 2.4.2 respectively in Jenkins.
What is happening:
A.war -> a.jar(whose original size is 1234 kb but it's coming 3 kb (which is the size of pointer file)
so my questions are:
This can be done using the regular Git+Plugin for Jenkins (version 3.1.0 onwards).
If you are using Jenkins Pipelines (i.e. with a Jenkinsfile in the root of your repo), the key thing is to include the extension [$class: 'GitLFSPull']
in your checkout()
call. Here is an (edited) example taken from one of our repos:
checkout([ $class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'GitLFSPull'],
[$class: 'CheckoutOption', timeout: 20],
[$class: 'CloneOption',
depth: 0,
noTags: false,
reference: '/other/optional/local/reference/clone',
shallow: false,
timeout: 120]
],
submoduleCfg: [],
userRemoteConfigs: [
[credentialsId: 'foobar',
url: 'https://github.com/foo/bar.git']
]
])
Using the Snippet Generator it is possible to generate this code, by selecting "Git LFS pull after checkout" from the "Additional Behaviours" menu. See screenshot here
This can be done with "Pre SCM BuildStep” Plugin.
Add “Pre SCM BuildStep” Plugin in Jenkins.
In Job Configuration
Select the property Run buildstep before SCM runs in Build Environment Section
Click on Add Build Step
Select Execute Shell or Execute Windows batch command.
Add the following command in the shell,
git lfs install
In the Source Code Management section -> Additional Behaviours -> Add Git LFS pull after checkout.
Reference Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With