Search code examples
jenkins-pipelinejenkins-declarative-pipeline

Are multiple values for "extensions" allowed in Jenkins checkout pipeline step?


Referring to the "extensions" property in the workflow scm step, it's declared as an Array/List with a "nested choice of objects".

I'd like to do something similar to the following:

checkout(
  [
    $class: 'GitSCM',
    extensions: [
      [$class: 'CloneOption', timeout: 15],
      [$class: 'AuthorInChangelog']
    ],
    ...
  ]
)

Is checkout.extensions truly an Array/List of Arrays/Lists?


Solution

  • Yes you can specify multiple extensions, below is an example which works fine for me

    checkout changelog: changelog, poll: true, scm: [
                $class: 'GitSCM',
                branches: [[name: "${branchName}"]],
                doGenerateSubmoduleConfigurations: false,
                extensions: [[$class: 'CloneOption', timeout: 60],
                             [$class: 'SubmoduleOption', recursiveSubmodules: true, parentCredentials: true, timeout: 60],
                             [$class: 'PruneStaleBranch']],
                submoduleCfg: [],
                userRemoteConfigs: [[name: 'origin', url: "${env.GITLAB_SSH}/${projectName}.git", credentialsId: 'jenkins']]
        ]