blob: cf6e0e4ea9c14988cdf6ab5c7527fcf1f16e1a10 [file] [log] [blame]
Denis Egorenkoff32a4d2016-12-21 14:41:53 +00001def call(body) {
2 // evaluate the body block, and collect configuration into the object
3 def config = [:]
4 body.resolveStrategy = Closure.DELEGATE_FIRST
5 body.delegate = config
6 body()
7
8 def merge = config.withMerge ?: false
9 def wipe = config.withWipeOut ?: false
10 def targetDir = config.targetDir ?: "./"
11 def port = config.port ?: "29418"
12
13 // default parameters
14 def scmExtensions = [
15 [$class: 'CleanCheckout'],
16 [$class: 'RelativeTargetDirectory', relativeTargetDir: "${targetDir}"]
17 ]
18
19 // https://issues.jenkins-ci.org/browse/JENKINS-6856
20 if (merge) {
21 scmExtensions.add([$class: 'LocalBranch', localBranch: "${config.branch}"])
22 }
23 // we need wipe workspace before checkout
24 if (wipe) {
25 scmExtensions.add([$class: 'WipeWorkspace'])
26 }
27
28 checkout(
29 scm: [
30 $class: 'GitSCM',
31 branches: [[name: "${config.branch}"]],
32 extensions: scmExtensions,
33 userRemoteConfigs: [[
34 credentialsId: "${config.credentialsId}",
35 name: 'origin',
36 url: "ssh://${config.credentialsId}@${config.host}:${port}/${config.project}.git"
37 ]]
38 ]
39 )
40}