Improved env property handling in Gerrit.groovy
Change-Id: I80a53bbe0b64d3c003b1b658b6ce55f12e1576f0
diff --git a/src/com/mirantis/mk/Gerrit.groovy b/src/com/mirantis/mk/Gerrit.groovy
index 932cb06..6de6b1d 100644
--- a/src/com/mirantis/mk/Gerrit.groovy
+++ b/src/com/mirantis/mk/Gerrit.groovy
@@ -31,12 +31,13 @@
def merge = config.get('withMerge', false)
def wipe = config.get('withWipeOut', false)
def credentials = config.get('credentialsId','')
- def gerritRefSpec = config.get('gerritRefSpec', GERRIT_REFSPEC)
- def gerritName = config.get('gerritName', GERRIT_NAME)
- def gerritHost = config.get('gerritHost', GERRIT_HOST)
- def gerritPort = config.get('gerritPort', GERRIT_PORT)
- def gerritProject = config.get('gerritProject', GERRIT_PROJECT)
- def gerritBranch = config.get('gerritBranch', GERRIT_BRANCH)
+ def gerritScheme = config.get('gerritScheme', env["GERRIT_SCHEME"] ? env["GERRIT_SCHEME"] : "")
+ def gerritRefSpec = config.get('gerritRefSpec', env["GERRIT_REFSPEC"] ? env["GERRIT_REFSPEC"] : "")
+ def gerritName = config.get('gerritName', env["GERRIT_NAME"] ? env["GERRIT_NAME"] : "")
+ def gerritHost = config.get('gerritHost', env["GERRIT_HOST"] ? env["GERRIT_HOST"] : "")
+ def gerritPort = config.get('gerritPort', env["GERRIT_PORT"] ? env["GERRIT_PORT"] : "")
+ def gerritProject = config.get('gerritProject', env["GERRIT_PROJECT"] ? env["GERRIT_PROJECT"] : "")
+ def gerritBranch = config.get('gerritBranch', env["GERRIT_BRANCH"] ? env["GERRIT_BRANCH"] : "")
def path = config.get('path', "")
def depth = config.get('depth', 0)
def timeout = config.get('timeout', 20)
@@ -55,7 +56,7 @@
if (credentials == '') {
// then try to checkout in anonymous mode
- scmUserRemoteConfigs.put('url',"https://${gerritHost}/${gerritProject}")
+ scmUserRemoteConfigs.put('url',"${gerritScheme}://${gerritHost}/${gerritProject}")
} else {
// else use ssh checkout
scmUserRemoteConfigs.put('url',"ssh://${gerritName}@${gerritHost}:${gerritPort}/${gerritProject}.git")