1
0

загрузка расширений с отключением безопасного режима (#14)

This commit is contained in:
Dima Ovcharenko
2023-07-07 15:07:42 +03:00
committed by Dima
parent 37a219f8a9
commit b00202df77
2 changed files with 58 additions and 32 deletions

View File

@@ -12,7 +12,7 @@ class Yaxunit implements Serializable {
private final JobConfiguration config 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' private final String DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE = 'yaxunit.json'
@@ -43,32 +43,38 @@ class Yaxunit implements Serializable {
String vrunnerPath = VRunner.getVRunnerPath() String vrunnerPath = VRunner.getVRunnerPath()
String ibConnection = ' --ibconnection "/F./build/ib"' String ibConnection = ' --ibconnection "/F./build/ib"'
// Скачиваем расширение // Скачиваем YAXUnit
String pathToYaxunit = "$env.WORKSPACE/$yaxunitPath" String pathToYaxunit = "$env.WORKSPACE/$yaxunitPath"
FilePath localPathToYaxunit = FileUtils.getFilePath(pathToYaxunit) FilePath localPathToYaxunit = FileUtils.getFilePath(pathToYaxunit)
Logger.println("Скачивание Yaxunit в $localPathToYaxunit") Logger.println("Скачивание YAXUnit в $localPathToYaxunit из ${options.cfe}")
localPathToYaxunit.copyFrom(new URL(options.cfe)) localPathToYaxunit.copyFrom(new URL(options.cfe))
// Команда загрузки YAXUnit def extCommands = []
String loadYaxunitCommand = vrunnerPath + ' run --command "Путь=' + pathToYaxunit + ';ЗавершитьРаботуСистемы;" --execute '
String executeParameter = '$runnerRoot/epf/ЗагрузитьРасширениеВРежимеПредприятия.epf'
if (steps.isUnix()) {
executeParameter = '\\' + executeParameter
}
loadYaxunitCommand += executeParameter
loadYaxunitCommand += ' --ibconnection "/F./build/ib"'
// Команда сборки расширений с тестами и их загрузки в ИБ // Команда загрузки YAXUnit
def loadTestExtCommands = [] def loadYaxunitCommand = VRunner.loadExtCommand("yaxunit")
extCommands << loadYaxunitCommand
// Команды сборки расширений с тестами и их загрузки в ИБ
for (String extension in options.extensionNames) { for (String extension in options.extensionNames) {
if (extension == "YAXUNIT") { if (extension.toUpperCase() == "YAXUNIT") {
continue continue
} }
def loadTestExtCommand = "$vrunnerPath compileext ./src/cfe/$extension $extension --updatedb $ibConnection"
loadTestExtCommands << loadTestExtCommand // Команда компиляции в cfe
Logger.println("Команда сборки расширения: $loadTestExtCommands") 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 String yaxunitConfigPath = options.configPath
File yaxunitConfigFile = new File("$env.WORKSPACE/$yaxunitConfigPath") File yaxunitConfigFile = new File("$env.WORKSPACE/$yaxunitConfigPath")
if (!steps.fileExists(yaxunitConfigPath)) { if (!steps.fileExists(yaxunitConfigPath)) {
@@ -78,28 +84,25 @@ class Yaxunit implements Serializable {
def yaxunitConfig = yaxunitConfigFile.getCanonicalPath() def yaxunitConfig = yaxunitConfigFile.getCanonicalPath()
// Команда запуска тестов // Команда запуска тестов
String command = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection" String runTestsCommand = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection"
// Переопределяем настройки vrunner // Переопределяем настройки vrunner
String vrunnerSettings = options.vrunnerSettings String vrunnerSettings = options.vrunnerSettings
String[] loadTestExtCommandJoined = loadTestExtCommands String[] extCommandsWithSettings = extCommands
if (steps.fileExists(vrunnerSettings)) { if (steps.fileExists(vrunnerSettings)) {
String vrunnerSettingsCommand = " --settings $vrunnerSettings" String vrunnerSettingsParam = " --settings $vrunnerSettings"
loadYaxunitCommand += vrunnerSettingsCommand extCommandsWithSettings = extCommands.collect { "$it $vrunnerSettingsParam" }
runTestsCommand += vrunnerSettingsParam
loadTestExtCommandJoined = loadTestExtCommands.collect { "$it $vrunnerSettingsCommand" }
command += vrunnerSettingsCommand
} }
// Выполяем команды // Выполяем команды
steps.withEnv(logosConfig) { steps.withEnv(logosConfig) {
VRunner.exec(loadYaxunitCommand, true) for (extCommand in extCommandsWithSettings) {
for (loadTestExtCommand in loadTestExtCommandJoined) { VRunner.exec(extCommand, true)
VRunner.exec(loadTestExtCommand, true)
} }
VRunner.exec(command, true) VRunner.exec(runTestsCommand, true)
} }
// Сохраняем результаты // Сохраняем результаты

View File

@@ -1,5 +1,6 @@
package ru.pulsar.jenkins.library.utils package ru.pulsar.jenkins.library.utils
import hudson.FilePath
import ru.pulsar.jenkins.library.IStepExecutor import ru.pulsar.jenkins.library.IStepExecutor
import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.ioc.ContextRegistry
@@ -11,13 +12,13 @@ class VRunner {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
String vrunnerBinary = steps.isUnix() ? "vrunner" : "vrunner.bat"; String vrunnerBinary = steps.isUnix() ? "vrunner" : "vrunner.bat"
String vrunnerPath = "oscript_modules/bin/$vrunnerBinary"; String vrunnerPath = "oscript_modules/bin/$vrunnerBinary"
if (!steps.fileExists(vrunnerPath)) { if (!steps.fileExists(vrunnerPath)) {
vrunnerPath = vrunnerBinary; vrunnerPath = vrunnerBinary
} }
return vrunnerPath; return vrunnerPath
} }
static int exec(String command, boolean returnStatus = false) { static int exec(String command, boolean returnStatus = false) {
@@ -38,4 +39,26 @@ class VRunner {
String fileContent = steps.readFile(configPath) String fileContent = steps.readFile(configPath)
return fileContent.contains("\"$settingName\"") 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
}
} }