Fix passing refspec to checkout command
Change-Id: I63ea15214af920174e8a3e24c77ad744a02d3f47
Related-Prod: PROD-32961
diff --git a/src/com/mirantis/mk/Git.groovy b/src/com/mirantis/mk/Git.groovy
index 00df961..9195c9b 100644
--- a/src/com/mirantis/mk/Git.groovy
+++ b/src/com/mirantis/mk/Git.groovy
@@ -19,19 +19,20 @@
* @param reference Git reference param to checkout (default empyt, i.e. no reference)
*/
def checkoutGitRepository(path, url, branch, credentialsId = null, poll = true, timeout = 10, depth = 0, reference = ''){
+ def branch_name = reference ? 'FETCH_HEAD' : "*/${branch}"
dir(path) {
checkout(
changelog:true,
poll: poll,
scm: [
$class: 'GitSCM',
- branches: [[name: "*/${branch}"]],
+ branches: [[name: branch_name]],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'CheckoutOption', timeout: timeout],
- [$class: 'CloneOption', depth: depth, noTags: false, reference: reference, shallow: depth > 0, timeout: timeout]],
+ [$class: 'CloneOption', depth: depth, noTags: false, shallow: depth > 0, timeout: timeout]],
submoduleCfg: [],
- userRemoteConfigs: [[url: url, credentialsId: credentialsId]]]
+ userRemoteConfigs: [[url: url, credentialsId: credentialsId, refspec: reference]]]
)
sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
}