Jenkins中的Git LFS设置 [英] Git LFS setup in jenkins

查看:472
本文介绍了Jenkins中的Git LFS设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jenkins中使用git LFS有问题.我现在正在做的是

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

  1. 我正在从Maven到Jenkins进行战争,战争包含一个jar文件
  2. 通过Git LFS,我们已将该jar文件转换为指针文件.但是在从詹金斯结帐的过程中,罐子并没有转换为原始大小,而是作为指针被包含在战争中.

我们在Jenkins中分别使用了版本3.3.0和2.4.2的git插件和git-client插件.

We have used git plugin and git-client plugin with version 3.3.0 and 2.4.2 respectively in Jenkins.

发生了什么事

A.war-> a.jar(其原始大小为1234 kb,但即将到来3 kb(这是指针文件的大小)

A.war -> a.jar(whose original size is 1234 kb but it's coming 3 kb (which is the size of pointer file)

所以我的问题是:

  1. 如何在Jenkins中使用git LFS?
  2. Jenkins是否有单独的Git Lfs插件?
  3. 使用Git LfS时在结帐时如何将文件转换为原始大小?

推荐答案

可以使用常规的

This can be done using the regular Git+Plugin for Jenkins (version 3.1.0 onwards).

如果您使用的是Jenkins Pipelines(即在回购的根目录中有一个Jenkinsfile),关键是要在您的checkout()调用中包括扩展名[$class: 'GitLFSPull'].这是摘自我们的一个回购中的一个(经过编辑的)示例:

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']
        ]
    ])

使用代码段生成器,可以通过从其他行为"菜单中选择结帐后Git LFS拉取"来生成此代码. 在此处查看屏幕截图

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

这篇关于Jenkins中的Git LFS设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆