Sergey Kulanov | 72f763e | 2016-09-29 17:08:44 +0300 | [diff] [blame] | 1 | def 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 | |
Igor Belikov | 4dc96cd | 2016-09-30 12:26:18 +0300 | [diff] [blame^] | 8 | def targetDir = config.targetDir ?: "./" |
Sergey Kulanov | 72f763e | 2016-09-29 17:08:44 +0300 | [diff] [blame] | 9 | def port = config.port ?: "29418" |
| 10 | |
| 11 | stage("Git Checkout"){ |
| 12 | checkout( |
| 13 | scm: [ |
| 14 | $class: 'GitSCM', |
| 15 | branches: [[name: "${config.branch}"]], |
| 16 | extensions: [ |
| 17 | [$class: 'CleanCheckout'], |
Igor Belikov | 4dc96cd | 2016-09-30 12:26:18 +0300 | [diff] [blame^] | 18 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "${targetDir}"] |
Sergey Kulanov | 72f763e | 2016-09-29 17:08:44 +0300 | [diff] [blame] | 19 | ], |
| 20 | userRemoteConfigs: [[ |
| 21 | credentialsId: "${config.credentialsId}", |
| 22 | name: 'origin', |
| 23 | url: "ssh://${config.credentialsId}@${config.host}:${port}/${config.project}.git" |
| 24 | ]] |
| 25 | ] |
| 26 | ) |
| 27 | } |
| 28 | } |