jenkinsjenkins-pipelinejenkins-job-dsl

jenkins how to enable checkout lightweight for pipelineJob?


Here is my job DSL which creates pipelinejob in which script is taken from scm itself.

pipelineJob ("${jobName}_deploy") {
  description("built by seed")

definition {
     cpsScm {
        scm {
            git {
                remote {
                    url('gitUrl')
                    credentials('user_creds')
                }
              branch('master')
            }
        }
        scriptPath "scripts/pipeline/jenkinsfile_deploy"
    }
 }
 }

I need the lightweight checkout should be checked automatically. enter image description here

any help would be more appreciated. I have so many jobs in which i need to open each and every job and click that check box which is painful.


Solution

  • You can use a Configure Block to add any option that is missing in the built-in DSL:

    pipelineJob('example') {
      definition {
        cpsScm {
          // ...
        } 
      }
      configure {
         it / definition / lightweight(true)
      }
    }