From b00202df77f3131f275e9e5e420f2be929b07e43 Mon Sep 17 00:00:00 2001 From: Dima Ovcharenko Date: Fri, 7 Jul 2023 15:07:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D1=81=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC?= =?UTF-8?q?=D0=B0=20(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/steps/Yaxunit.groovy | 59 ++++++++++--------- .../jenkins/library/utils/VRunner.groovy | 31 ++++++++-- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy index bbf98c8..af1f861 100644 --- a/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Yaxunit.groovy @@ -12,7 +12,7 @@ class Yaxunit implements Serializable { private final JobConfiguration config - private final String yaxunitPath = 'build/yaxunit.cfe' + private final String yaxunitPath = 'build/out/yaxunit.cfe' private final String DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE = 'yaxunit.json' @@ -43,32 +43,38 @@ class Yaxunit implements Serializable { String vrunnerPath = VRunner.getVRunnerPath() String ibConnection = ' --ibconnection "/F./build/ib"' - // Скачиваем расширение + // Скачиваем YAXUnit String pathToYaxunit = "$env.WORKSPACE/$yaxunitPath" FilePath localPathToYaxunit = FileUtils.getFilePath(pathToYaxunit) - Logger.println("Скачивание Yaxunit в $localPathToYaxunit") + Logger.println("Скачивание YAXUnit в $localPathToYaxunit из ${options.cfe}") localPathToYaxunit.copyFrom(new URL(options.cfe)) - // Команда загрузки YAXUnit - String loadYaxunitCommand = vrunnerPath + ' run --command "Путь=' + pathToYaxunit + ';ЗавершитьРаботуСистемы;" --execute ' - String executeParameter = '$runnerRoot/epf/ЗагрузитьРасширениеВРежимеПредприятия.epf' - if (steps.isUnix()) { - executeParameter = '\\' + executeParameter - } - loadYaxunitCommand += executeParameter - loadYaxunitCommand += ' --ibconnection "/F./build/ib"' + def extCommands = [] - // Команда сборки расширений с тестами и их загрузки в ИБ - def loadTestExtCommands = [] + // Команда загрузки YAXUnit + def loadYaxunitCommand = VRunner.loadExtCommand("yaxunit") + extCommands << loadYaxunitCommand + + + // Команды сборки расширений с тестами и их загрузки в ИБ for (String extension in options.extensionNames) { - if (extension == "YAXUNIT") { + if (extension.toUpperCase() == "YAXUNIT") { continue } - def loadTestExtCommand = "$vrunnerPath compileext ./src/cfe/$extension $extension --updatedb $ibConnection" - loadTestExtCommands << loadTestExtCommand - Logger.println("Команда сборки расширения: $loadTestExtCommands") + + // Команда компиляции в cfe + def compileExtCommand = "$vrunnerPath compileexttocfe --src ./src/cfe/$extension --out build/out/${extension}.cfe" + extCommands << compileExtCommand + Logger.println("Команда сборки расширения: $compileExtCommand") + + // Команда загрузки расширения в ИБ + def loadTestExtCommand = VRunner.loadExtCommand(extension) + extCommands << loadTestExtCommand + Logger.println("Команда загрузки расширения: $loadTestExtCommand") + } + // Готовим конфиг для yaxunit String yaxunitConfigPath = options.configPath File yaxunitConfigFile = new File("$env.WORKSPACE/$yaxunitConfigPath") if (!steps.fileExists(yaxunitConfigPath)) { @@ -78,28 +84,25 @@ class Yaxunit implements Serializable { def yaxunitConfig = yaxunitConfigFile.getCanonicalPath() // Команда запуска тестов - String command = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection" + String runTestsCommand = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection" // Переопределяем настройки vrunner String vrunnerSettings = options.vrunnerSettings - String[] loadTestExtCommandJoined = loadTestExtCommands + String[] extCommandsWithSettings = extCommands if (steps.fileExists(vrunnerSettings)) { - String vrunnerSettingsCommand = " --settings $vrunnerSettings" + String vrunnerSettingsParam = " --settings $vrunnerSettings" - loadYaxunitCommand += vrunnerSettingsCommand - - loadTestExtCommandJoined = loadTestExtCommands.collect { "$it $vrunnerSettingsCommand" } - command += vrunnerSettingsCommand + extCommandsWithSettings = extCommands.collect { "$it $vrunnerSettingsParam" } + runTestsCommand += vrunnerSettingsParam } // Выполяем команды steps.withEnv(logosConfig) { - VRunner.exec(loadYaxunitCommand, true) - for (loadTestExtCommand in loadTestExtCommandJoined) { - VRunner.exec(loadTestExtCommand, true) + for (extCommand in extCommandsWithSettings) { + VRunner.exec(extCommand, true) } - VRunner.exec(command, true) + VRunner.exec(runTestsCommand, true) } // Сохраняем результаты diff --git a/src/ru/pulsar/jenkins/library/utils/VRunner.groovy b/src/ru/pulsar/jenkins/library/utils/VRunner.groovy index fdf37e2..ce06555 100644 --- a/src/ru/pulsar/jenkins/library/utils/VRunner.groovy +++ b/src/ru/pulsar/jenkins/library/utils/VRunner.groovy @@ -1,5 +1,6 @@ package ru.pulsar.jenkins.library.utils +import hudson.FilePath import ru.pulsar.jenkins.library.IStepExecutor import ru.pulsar.jenkins.library.ioc.ContextRegistry @@ -11,13 +12,13 @@ class VRunner { IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() - String vrunnerBinary = steps.isUnix() ? "vrunner" : "vrunner.bat"; - String vrunnerPath = "oscript_modules/bin/$vrunnerBinary"; + String vrunnerBinary = steps.isUnix() ? "vrunner" : "vrunner.bat" + String vrunnerPath = "oscript_modules/bin/$vrunnerBinary" if (!steps.fileExists(vrunnerPath)) { - vrunnerPath = vrunnerBinary; + vrunnerPath = vrunnerBinary } - return vrunnerPath; + return vrunnerPath } static int exec(String command, boolean returnStatus = false) { @@ -38,4 +39,26 @@ class VRunner { String fileContent = steps.readFile(configPath) return fileContent.contains("\"$settingName\"") } + + static String loadExtCommand(String name) { + + IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() + + def env = steps.env() + def vrunnerPath = getVRunnerPath() + + String pathToExt = "$env.WORKSPACE/build/out/${name}.cfe" + FilePath localPathToExt = FileUtils.getFilePath(pathToExt) + + // Команда загрузки расширения + String loadCommand = vrunnerPath + ' run --command "Путь=' + localPathToExt + ';ЗавершитьРаботуСистемы;" --execute ' + String executeParameter = '$runnerRoot/epf/ЗагрузитьРасширениеВРежимеПредприятия.epf' + if (steps.isUnix()) { + executeParameter = '\\' + executeParameter + } + loadCommand += executeParameter + loadCommand += ' --ibconnection "/F./build/ib"' + + return loadCommand + } }