diff --git a/first-class-pipeline/tests/Jenkinsfile b/first-class-pipeline/tests/Jenkinsfile index cb44b23c..56d93fa4 100644 --- a/first-class-pipeline/tests/Jenkinsfile +++ b/first-class-pipeline/tests/Jenkinsfile @@ -1,14 +1,13 @@ #!groovy library 'first-class-pipeline' - def configurations = [:] - configurations.put('SERVICE_NAME', 'magicleaps') - configurations.put('SERVICE_LANG', 'Python') - configurations.put('SERVICE_GIT_REPO', 'https://freeleaps@dev.azure.com/freeleaps/magicleaps/_git/magicleaps') - configurations.put('SERVICE_GIT_BRANCH', 'master') - configurations.put('ENVIRONMENT_SLUG', 'alpha') - configurations.put('PY_DEPENDENCIES_MANAGER', 'PIP') - configurations.put('REQUIREMENTS_FILE_PATH', 'requirements.txt') - -pipelineCall(configurations) \ No newline at end of file +pipelineCall { + SERVICE_NAME = 'magicleaps' + SERVICE_LANG = 'Python' + SERVICE_GIT_BRANCH = 'master' + SERVICE_GIT_REPO = "https://freeleaps@dev.azure.com/freeleaps/magicleaps/_git/magicleaps", + ENVIRONMENT_SLUG = 'alpha' + PY_DEPENDENCIES_MANAGER = 'PIP' + REQUIREMENTS_FILE_PATH = 'requirements.txt' +} \ No newline at end of file diff --git a/first-class-pipeline/vars/pipelineCall.groovy b/first-class-pipeline/vars/pipelineCall.groovy index 0db3d709..52abe28e 100644 --- a/first-class-pipeline/vars/pipelineCall.groovy +++ b/first-class-pipeline/vars/pipelineCall.groovy @@ -5,7 +5,12 @@ import com.freeleaps.devops.SourceFetcher import com.freeleaps.devops.DependenciesResolver import com.freeleaps.devops.enums.DependenciesManager -def call(Map configurations) { +def call(configurations) { + def configurationMap = [:] + configurations.resolveStrategy = Closure.DELEGATE_FIRST + configurations.delegate = configurationMap + configurations() + def environmentVars = new EnvironmentVars(this) pipeline { @@ -21,7 +26,7 @@ def call(Map configurations) { steps { script { def sourceFetcher = new SourceFetcher(this) - sourceFetcher.fetch(configurations) + sourceFetcher.fetch(configurationMap) } } } @@ -29,7 +34,7 @@ def call(Map configurations) { stage("Prepared Environment Variables") { steps { script { - environmentVars.injectVars(configurations) + environmentVars.injectVars(configurationMap) } } } @@ -49,7 +54,7 @@ def call(Map configurations) { stage("Build Agent Setup") { steps { script { - def buildAgentImage = configurations.BUILD_AGENT_IMAGE + def buildAgentImage = configurationMap.BUILD_AGENT_IMAGE if (buildAgentImage != null && !buildAgentImage.isEmpty()) { echo "Not set BUILD_AGENT_IMAGE, using default build agent image" @@ -99,7 +104,7 @@ spec: script { def language = env.SERVICE_LANG - def depManager = DependenciesManager.parse(configurations.DEPENDENCIES_MANAGER) + def depManager = DependenciesManager.parse(configurationMap.DEPENDENCIES_MANAGER) if (depManager == DependenciesManager.UNKNOWN) { error("Unknown dependencies manager") } @@ -107,13 +112,13 @@ spec: def dependenciesResolver = new DependenciesResolver(this, language) dependenciesResolver.useManager(depManager) - if (configurations.BUILD_CACHE_ENABLED == "true") { + if (configurationMap.BUILD_CACHE_ENABLED == "true") { dependenciesResolver.enableCachingSupport() } else { dependenciesResolver.disableCachingSupport() } - dependenciesResolver.resolve(configurations) + dependenciesResolver.resolve(configurationMap) } } }