小编典典

使用Jenkins DSL插件进行稀疏签出?

jenkins

有没有人有正确的代码示例

configure { ... }

Jenkins DSL插件中需要设置块来设置git稀疏签出吗?

好像config.xml部分看起来像这样:

<extensions>
  <hudson.plugins.git.extensions.impl.CloneOption>
    <shallow>false</shallow>
    <reference>/build/jenkins/codebase.git</reference>
  </hudson.plugins.git.extensions.impl.CloneOption>
  <hudson.plugins.git.extensions.impl.SparseCheckoutPaths>
    <sparseCheckoutPaths>
      <hudson.plugins.git.extensions.impl.SparseCheckoutPath>
        <path>BillOfMaterials.yml</path>
      </hudson.plugins.git.extensions.impl.SparseCheckoutPath>
      <hudson.plugins.git.extensions.impl.SparseCheckoutPath>
        <path>jenkins/job/</path>
      </hudson.plugins.git.extensions.impl.SparseCheckoutPath>
    </sparseCheckoutPaths>
  </hudson.plugins.git.extensions.impl.SparseCheckoutPaths>
</extensions>

阅读 404

收藏
2020-07-25

共1个答案

小编典典

job('job1') {
    description 'sparse checkout example'
    scm {
        git {
            reference('/build/jenkins/codebase.git')
            configure { git ->
                git / 'extensions' / 'hudson.plugins.git.extensions.impl.SparseCheckoutPaths' / 'sparseCheckoutPaths' {
                    ['mypath1', 'mypath2', 'mypath3'].each { mypath ->
                        'hudson.plugins.git.extensions.impl.SparseCheckoutPath' {
                            path("${mypath}")
                        }
                    }
                }
            }
        }
    }
}
2020-07-25