Git LFS setup in jenkins

前端 未结 2 1891
暗喜
暗喜 2021-02-09 01:45

I have an issue with git LFS use in Jenkins. What I am doing now is that

  1. I am building a war from maven through Jenkins that war contains a jar file
  2. thro
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 02:22

    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

提交回复
热议问题