1

We are using the Jenkins Configuration As Code (JCAC) plugin to automate the jenkins configuration. One of the challenges is to set git-lfs as an additional checkout behavior.

GitLFSPull has to be configured, but it does not seem to be included in the DSL:

enter image description here

The README of the JCAC github repository indicates that support questions should be asked on Gitter

According to this Q&A, GitLFSPull should be an extension:

extensions: [[$class: 'GitLFSPull']]

However, querying for this on the Job DSL page shows that GitLFSPull seems to be omitted:

enter image description here

030
  • 13,383
  • 17
  • 76
  • 178

1 Answers1

1

It seems that it is only possible by using a workaround as depicted in this answer.

After setting gitLFS in the UI, subsequently inspecting the /var/lib/jenkins/jobs/some-job/config.xml file it became obvious that the XML looked as follows:

<traits>
   <jenkins.plugins.git.traits.GitLFSPullTrait>
      <extension class="hudson.plugins.git.extensions.impl.GitLFSPull"/>
   </jenkins.plugins.git.traits.GitLFSPullTrait>
</traits

After defining jenkins.plugins.git.traits.GitLFSPullTrait:

jobs:
  - script: >
      multibranchPipelineJob("example") {
        branchSources {
          ...
        }
        configure { node ->
          node / sources / data / 'jenkins.branch.BranchSource' / source / traits {
            'jenkins.plugins.git.traits.GitLFSPullTrait'()
          }
        }
      }

Git-lfs was enabled.

030
  • 13,383
  • 17
  • 76
  • 178