From a76fc26dede65e891df7a15964dab12bd4e4bc6e Mon Sep 17 00:00:00 2001 From: Dima Date: Sat, 9 Nov 2024 16:06:47 +0300 Subject: [PATCH 01/12] designer to edt transform with 1cedtcli --- .../DesignerToEdtFormatTransformation.groovy | 23 ++++++++++++-- .../library/utils/VersionParser.groovy | 18 +++++++++++ .../library/utils/VersionParserTest.java | 30 +++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index 320fb609..572f2fa1 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -7,6 +7,7 @@ import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger +import ru.pulsar.jenkins.library.utils.VersionParser class DesignerToEdtFormatTransformation implements Serializable { @@ -36,15 +37,31 @@ class DesignerToEdtFormatTransformation implements Serializable { def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") def projectName = configurationRoot.getName() - def edtVersionForRing = EDT.ringModule(config) steps.deleteDir(workspaceDir) Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") - def ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $projectName --workspace-location \"$workspaceDir\"" + if (VersionParser.compare(config.edtVersion, "2024") < 0) { - steps.ringCommand(ringCommand) + Logger.println("Версия EDT меньше 2024.1.X, используется ring") + + def edtVersionForRing = EDT.ringModule(config) + def ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $projectName --workspace-location \"$workspaceDir\"" + + steps.ringCommand(ringCommand) + + } else { + + Logger.println("Версия EDT больше 2024.1.X, используется 1cedtcli") + + def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name $projectName" + + def stdOut = steps.cmd(edtcliCommand, false, true) + + Logger.println(stdOut) + + } steps.zip(WORKSPACE, WORKSPACE_ZIP) steps.stash(WORKSPACE_ZIP_STASH, WORKSPACE_ZIP) diff --git a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy index 4914cdf8..925a3c47 100644 --- a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy +++ b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy @@ -43,4 +43,22 @@ class VersionParser implements Serializable { return matcher != null && matcher.getCount() == 1 ? matcher[0][1] : "" } + static int compare(String thisVersion, String thatVersion) { + + def thisVersionParts = thisVersion.split("\\.") + def thatVersionParts = thatVersion.split("\\.") + + def minIndex = Math.min(thisVersionParts.length, thatVersionParts.length) + + for (int i = 0;i < minIndex;i++) { + + if (thisVersionParts[i].toInteger() > thatVersionParts[i].toInteger()) { + return 1 + } else if (thisVersionParts[i].toInteger() < thatVersionParts[i].toInteger()) { + return -1 + } + } + + return 0 + } } diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java index 3ef626cb..afa03ae5 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java @@ -85,4 +85,34 @@ void testConfiguration() throws IOException { assertThat(storage).isEqualTo("1.0.0.1"); } + @Test + void testVersionComparisonLessThan() { + + // given + String thisVersion = "2023.2.4"; + String thatVersion = "2023.3.1"; + + // when + int result = VersionParser.compare(thisVersion, thatVersion); + + // then + assertThat(result).isEqualTo(-1); + + } + + @Test + void testVersionComparisonEqualShort() { + + // given + String thisVersion = "2024.2.4"; + String thatVersion = "2024.2"; + + // when + int result = VersionParser.compare(thisVersion, thatVersion); + + // then + assertThat(result).isEqualTo(0); + + } + } \ No newline at end of file From 56a4c8741da5be407eb6a8dd479ef4da920bd2a9 Mon Sep 17 00:00:00 2001 From: Dima Date: Sat, 9 Nov 2024 19:54:53 +0300 Subject: [PATCH 02/12] mv def --- .../library/steps/DesignerToEdtFormatTransformation.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index 572f2fa1..7a19feaf 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -36,7 +36,6 @@ class DesignerToEdtFormatTransformation implements Serializable { def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") - def projectName = configurationRoot.getName() steps.deleteDir(workspaceDir) @@ -55,6 +54,7 @@ class DesignerToEdtFormatTransformation implements Serializable { Logger.println("Версия EDT больше 2024.1.X, используется 1cedtcli") + def projectName = configurationRoot.getName() def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name $projectName" def stdOut = steps.cmd(edtcliCommand, false, true) From 9d1ab7bfcd9066f5dfc0e3983ffb9fa68317a6db Mon Sep 17 00:00:00 2001 From: Dima Date: Sat, 9 Nov 2024 19:55:48 +0300 Subject: [PATCH 03/12] edt to designer transform with 1cedtcli --- .../EdtToDesignerFormatTransformation.groovy | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index 672168ff..d7ae5b88 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -9,6 +9,7 @@ import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger +import ru.pulsar.jenkins.library.utils.VersionParser class EdtToDesignerFormatTransformation implements Serializable { @@ -60,9 +61,24 @@ class EdtToDesignerFormatTransformation implements Serializable { Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора") steps.deleteDir(configurationRoot) - def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$projectWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" + if (VersionParser.compare(config.edtVersion, "2024") < 0) { - steps.ringCommand(ringCommand) + Logger.println("Версия EDT меньше 2024.1.X, используется ring") + + def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$projectWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" + steps.ringCommand(ringCommand) + + } else { + + Logger.println("Версия EDT больше 2024.1.X, используется 1cedtcli") + + def projectName = configurationRoot.getName() + def edtcliCommand = "1cedtcli -data \"$projectWorkspaceDir\" -command export --configuration-files \"$configurationRoot\" --project-name $projectName" + + def stdOut = steps.cmd(edtcliCommand, false, true) + + Logger.println(stdOut) + } steps.zip(CONFIGURATION_DIR, CONFIGURATION_ZIP) steps.stash(CONFIGURATION_ZIP_STASH, CONFIGURATION_ZIP) @@ -83,9 +99,24 @@ class EdtToDesignerFormatTransformation implements Serializable { def projectDir = FileUtils.getFilePath("$env.WORKSPACE/${it.path}") def currentExtensionWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cfe/${it.name}") - def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$currentExtensionWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$extensionRoot/${it.name}\"" + if (VersionParser.compare(config.edtVersion, "2024") < 0) { - steps.ringCommand(ringCommand) + Logger.println("Версия EDT меньше 2024.1.X, для конвертации исходников расширения используется ring") + + def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$currentExtensionWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$extensionRoot/${it.name}\"" + steps.ringCommand(ringCommand) + + } else { + + Logger.println("Версия EDT больше 2024.1.X, для конвертации исходников расширения используется 1cedtcli") + + def edtcliCommand = "1cedtcli -data \"$currentExtensionWorkspaceDir\" -command export --configuration-files \"$extensionRoot/${it.name}\" --project-name ${it.name}" + + def stdOut = steps.cmd(edtcliCommand, false, true) + + Logger.println(stdOut) + + } } steps.zip(EXTENSION_DIR, EXTENSION_ZIP) steps.stash(EXTENSION_ZIP_STASH, EXTENSION_ZIP) From 1402449b83cd6c508d6232127ecc2db8fc714a7f Mon Sep 17 00:00:00 2001 From: Dima Date: Sat, 9 Nov 2024 20:01:17 +0300 Subject: [PATCH 04/12] edt validate with 1cedtcli --- .../jenkins/library/steps/EdtValidate.groovy | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 70efc79f..c94710bc 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -7,6 +7,7 @@ import ru.pulsar.jenkins.library.ioc.ContextRegistry import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger +import ru.pulsar.jenkins.library.utils.VersionParser class EdtValidate implements Serializable { @@ -55,9 +56,25 @@ class EdtValidate implements Serializable { Logger.println("Выполнение валидации EDT") - def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" - steps.catchError { - steps.ringCommand(ringCommand) + if (VersionParser.compare(config.edtVersion, "2024") < 0) { + + Logger.println("Версия EDT меньше 2024.1.X, для валидации используется ring") + + def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" + steps.catchError { + steps.ringCommand(ringCommand) + } + + } else { + + Logger.println("Версия EDT больше 2024.1.X, для валидации используется 1cedtcli") + + def edtcliCommand = "1cedtcli -data \"$workspaceLocation\" -command validate --file \"$resultFile\" $projectList" + steps.catchError { + def stdOut = steps.cmd(edtcliCommand, false, true) + Logger.println(stdOut) + } + } steps.archiveArtifacts("$DesignerToEdtFormatTransformation.WORKSPACE/.metadata/.log") From 21e59aed4855fddf1c3d01b3ea5518c0eb570a48 Mon Sep 17 00:00:00 2001 From: Dima Date: Sun, 10 Nov 2024 17:45:07 +0300 Subject: [PATCH 05/12] refactoring --- .../library/edt/EdtCliEngineFactory.groovy | 18 ++++ .../jenkins/library/edt/IEdtCliEngine.java | 11 ++ .../library/edt/NativeEdtCliConverter.groovy | 92 ++++++++++++++++ .../jenkins/library/edt/RingConverter.groovy | 101 ++++++++++++++++++ .../DesignerToEdtFormatTransformation.groovy | 38 +------ .../EdtToDesignerFormatTransformation.groovy | 81 +------------- .../jenkins/library/steps/EdtValidate.groovy | 28 +---- .../library/utils/VersionParser.groovy | 18 ---- .../library/utils/VersionParserTest.java | 30 ------ 9 files changed, 233 insertions(+), 184 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy create mode 100644 src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java create mode 100644 src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy create mode 100644 src/ru/pulsar/jenkins/library/edt/RingConverter.groovy diff --git a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy new file mode 100644 index 00000000..767638ab --- /dev/null +++ b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy @@ -0,0 +1,18 @@ +package ru.pulsar.jenkins.library.edt + +import java.lang.module.ModuleDescriptor + +class EdtCliEngineFactory { + + static IEdtCliEngine getEngine(String edtVersion) { + + def currentVersion = ModuleDescriptor.Version.parse(edtVersion) + def version2024 = ModuleDescriptor.Version.parse("2024") + + if (currentVersion < version2024) { + return new RingConverter() + } else { + return new NativeEdtCliConverter() + } + } +} diff --git a/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java b/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java new file mode 100644 index 00000000..ef498d75 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java @@ -0,0 +1,11 @@ +package ru.pulsar.jenkins.library.edt; + +import ru.pulsar.jenkins.library.IStepExecutor; +import ru.pulsar.jenkins.library.configuration.JobConfiguration; + +public interface IEdtCliEngine { + void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config); + void edtToDesignerTransformExtensions(IStepExecutor steps, JobConfiguration config); + void designerToEdtTransform(IStepExecutor steps, JobConfiguration config); + void edtValidate(IStepExecutor steps, JobConfiguration config, String projectList); +} diff --git a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy new file mode 100644 index 00000000..10869a80 --- /dev/null +++ b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy @@ -0,0 +1,92 @@ +package ru.pulsar.jenkins.library.edt + +import ru.pulsar.jenkins.library.IStepExecutor +import ru.pulsar.jenkins.library.configuration.InitExtensionMethod +import ru.pulsar.jenkins.library.configuration.JobConfiguration +import ru.pulsar.jenkins.library.steps.DesignerToEdtFormatTransformation +import ru.pulsar.jenkins.library.steps.EdtToDesignerFormatTransformation +import ru.pulsar.jenkins.library.steps.EdtValidate +import ru.pulsar.jenkins.library.utils.FileUtils +import ru.pulsar.jenkins.library.utils.Logger + +class NativeEdtCliConverter implements IEdtCliEngine { + + @Override + void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config) { + + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() + String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() + + Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора с помощью ring") + + steps.deleteDir(configurationRoot) + + def projectName = configurationRoot.getName() + def edtcliCommand = "1cedtcli -data \"$projectWorkspaceDir\" -command export --configuration-files \"$configurationRoot\" --project-name $projectName" + + steps.cmd(edtcliCommand) + + } + + @Override + void edtToDesignerTransformExtensions(IStepExecutor steps, JobConfiguration config) { + + def env = steps.env() + + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String extensionRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.EXTENSION_DIR").getRemote() + + config.initInfoBaseOptions.extensions.each { + + if (it.initMethod != InitExtensionMethod.SOURCE) { + return + } + + Logger.println("Конвертация исходников расширения ${it.name} из формата EDT в формат Конфигуратора с помощью 1cedtcli") + def currentExtensionWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cfe/${it.name}") + + def edtcliCommand = "1cedtcli -data \"$currentExtensionWorkspaceDir\" -command export --configuration-files \"$extensionRoot/${it.name}\" --project-name ${it.name}" + + steps.cmd(edtcliCommand) + + } + + } + + @Override + void designerToEdtTransform(IStepExecutor steps, JobConfiguration config) { + + def env = steps.env() + + def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") + def srcDir = config.srcDir + def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") + def projectName = configurationRoot.getName() + + steps.deleteDir(workspaceDir) + steps.deleteDir(configurationRoot) + + Logger.println("Конвертация исходников из формата конфигуратора в формат EDT с помощью 1cedtcli") + + def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name $projectName" + + steps.cmd(edtcliCommand) + + } + + @Override + void edtValidate(IStepExecutor steps, JobConfiguration config, String projectList) { + + def env = steps.env() + + String workspaceLocation = "$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE" + def resultFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" + + def edtcliCommand = "1cedtcli -data \"$workspaceLocation\" -command validate --file \"$resultFile\" $projectList" + steps.catchError { + steps.cmd(edtcliCommand) + } + + } +} diff --git a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy new file mode 100644 index 00000000..967a567a --- /dev/null +++ b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy @@ -0,0 +1,101 @@ +package ru.pulsar.jenkins.library.edt + +import ru.pulsar.jenkins.library.IStepExecutor +import ru.pulsar.jenkins.library.configuration.InitExtensionMethod +import ru.pulsar.jenkins.library.configuration.JobConfiguration +import ru.pulsar.jenkins.library.steps.DesignerToEdtFormatTransformation +import ru.pulsar.jenkins.library.steps.EdtToDesignerFormatTransformation +import ru.pulsar.jenkins.library.steps.EdtValidate +import ru.pulsar.jenkins.library.utils.EDT +import ru.pulsar.jenkins.library.utils.FileUtils +import ru.pulsar.jenkins.library.utils.Logger + +class RingConverter implements IEdtCliEngine { + + @Override + void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config) { + + def env = steps.env() + def edtVersionForRing = EDT.ringModule(config) + def srcDir = config.srcDir + + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() + String projectDir = FileUtils.getFilePath("$env.WORKSPACE/$srcDir").getRemote() + String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() + + Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора с помощью ring") + + steps.deleteDir(configurationRoot) + + def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$projectWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" + steps.ringCommand(ringCommand) + + } + + @Override + void edtToDesignerTransformExtensions(IStepExecutor steps, JobConfiguration config) { + + def env = steps.env() + + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + def edtVersionForRing = EDT.ringModule(config) + String extensionRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.EXTENSION_DIR").getRemote() + + config.initInfoBaseOptions.extensions.each { + + if (it.initMethod != InitExtensionMethod.SOURCE) { + return + } + + Logger.println("Конвертация исходников расширения ${it.name} из формата EDT в формат Конфигуратора с помощью ring") + + + def projectDir = FileUtils.getFilePath("$env.WORKSPACE/${it.path}") + def currentExtensionWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cfe/${it.name}") + def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$currentExtensionWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$extensionRoot/${it.name}\"" + steps.ringCommand(ringCommand) + } + } + + @Override + void designerToEdtTransform(IStepExecutor steps, JobConfiguration config) { + + def env = steps.env() + + def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") + def srcDir = config.srcDir + def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") + def projectName = configurationRoot.getName() + + steps.deleteDir(workspaceDir) + steps.deleteDir(configurationRoot) + + Logger.println("Конвертация исходников из формата конфигуратора в формат EDT с помощью ring") + + String edtVersionForRing = EDT.ringModule(config) + String ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $projectName --workspace-location \"$workspaceDir\"" + + steps.ringCommand(ringCommand) + + } + + @Override + void edtValidate(IStepExecutor steps, JobConfiguration config, String projectList) { + + def env = steps.env() + + def edtVersionForRing = EDT.ringModule(config) + String workspaceLocation = "$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE" + + def resultFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE" + + Logger.println("Версия EDT меньше 2024.1.X, для валидации используется ring") + + def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" + steps.catchError { + steps.ringCommand(ringCommand) + } + + } +} diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index 7a19feaf..e9aa06f8 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -1,13 +1,10 @@ package ru.pulsar.jenkins.library.steps - +import ru.pulsar.jenkins.library.edt.EdtCliEngineFactory import ru.pulsar.jenkins.library.IStepExecutor import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.ioc.ContextRegistry -import ru.pulsar.jenkins.library.utils.EDT -import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger -import ru.pulsar.jenkins.library.utils.VersionParser class DesignerToEdtFormatTransformation implements Serializable { @@ -31,37 +28,8 @@ class DesignerToEdtFormatTransformation implements Serializable { return } - def env = steps.env() - - def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") - def srcDir = config.srcDir - def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") - - steps.deleteDir(workspaceDir) - - Logger.println("Конвертация исходников из формата конфигуратора в формат EDT") - - if (VersionParser.compare(config.edtVersion, "2024") < 0) { - - Logger.println("Версия EDT меньше 2024.1.X, используется ring") - - def edtVersionForRing = EDT.ringModule(config) - def ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $projectName --workspace-location \"$workspaceDir\"" - - steps.ringCommand(ringCommand) - - } else { - - Logger.println("Версия EDT больше 2024.1.X, используется 1cedtcli") - - def projectName = configurationRoot.getName() - def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name $projectName" - - def stdOut = steps.cmd(edtcliCommand, false, true) - - Logger.println(stdOut) - - } + def engine = EdtCliEngineFactory.getEngine(config.edtVersion) + engine.designerToEdtTransform(steps, config) steps.zip(WORKSPACE, WORKSPACE_ZIP) steps.stash(WORKSPACE_ZIP_STASH, WORKSPACE_ZIP) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index d7ae5b88..13f5af05 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -1,15 +1,12 @@ package ru.pulsar.jenkins.library.steps - +import ru.pulsar.jenkins.library.edt.EdtCliEngineFactory import ru.pulsar.jenkins.library.IStepExecutor import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.configuration.SourceFormat -import ru.pulsar.jenkins.library.configuration.InitExtensionMethod import ru.pulsar.jenkins.library.ioc.ContextRegistry -import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger -import ru.pulsar.jenkins.library.utils.VersionParser class EdtToDesignerFormatTransformation implements Serializable { @@ -39,87 +36,19 @@ class EdtToDesignerFormatTransformation implements Serializable { def env = steps.env(); - String srcDir = config.srcDir String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() - - String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() - String projectDir = FileUtils.getFilePath("$env.WORKSPACE/$srcDir").getRemote() - String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$CONFIGURATION_DIR").getRemote() - - - String extensionRoot = FileUtils.getFilePath("$env.WORKSPACE/$EXTENSION_DIR").getRemote() - def edtVersionForRing = EDT.ringModule(config) - steps.deleteDir(workspaceDir) - transformConfiguration(steps, projectDir, projectWorkspaceDir, configurationRoot, edtVersionForRing) - transformExtensions(steps, workspaceDir, extensionRoot, edtVersionForRing) - } - - private void transformConfiguration(IStepExecutor steps, String projectDir, String projectWorkspaceDir, String configurationRoot, String edtVersionForRing) { - - Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора") - steps.deleteDir(configurationRoot) - - if (VersionParser.compare(config.edtVersion, "2024") < 0) { - - Logger.println("Версия EDT меньше 2024.1.X, используется ring") - - def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$projectWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\"" - steps.ringCommand(ringCommand) - - } else { - - Logger.println("Версия EDT больше 2024.1.X, используется 1cedtcli") - - def projectName = configurationRoot.getName() - def edtcliCommand = "1cedtcli -data \"$projectWorkspaceDir\" -command export --configuration-files \"$configurationRoot\" --project-name $projectName" - - def stdOut = steps.cmd(edtcliCommand, false, true) - - Logger.println(stdOut) - } + def engine = EdtCliEngineFactory.getEngine(config.edtVersion) + engine.edtToDesignerTransformConfiguration(steps, config) steps.zip(CONFIGURATION_DIR, CONFIGURATION_ZIP) steps.stash(CONFIGURATION_ZIP_STASH, CONFIGURATION_ZIP) - } - - private void transformExtensions(IStepExecutor steps, String workspaceDir, String extensionRoot, String edtVersionForRing) { - steps.deleteDir(extensionRoot) - - config.initInfoBaseOptions.extensions.each { - - if (it.initMethod != InitExtensionMethod.SOURCE) { - return - } - - Logger.println("Конвертация исходников расширения ${it.name} из формата EDT в формат Конфигуратора") - - def env = steps.env(); - def projectDir = FileUtils.getFilePath("$env.WORKSPACE/${it.path}") - def currentExtensionWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cfe/${it.name}") - - if (VersionParser.compare(config.edtVersion, "2024") < 0) { - - Logger.println("Версия EDT меньше 2024.1.X, для конвертации исходников расширения используется ring") - def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$currentExtensionWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$extensionRoot/${it.name}\"" - steps.ringCommand(ringCommand) - - } else { - - Logger.println("Версия EDT больше 2024.1.X, для конвертации исходников расширения используется 1cedtcli") - - def edtcliCommand = "1cedtcli -data \"$currentExtensionWorkspaceDir\" -command export --configuration-files \"$extensionRoot/${it.name}\" --project-name ${it.name}" - - def stdOut = steps.cmd(edtcliCommand, false, true) - - Logger.println(stdOut) - - } - } + engine.edtToDesignerTransformExtensions(steps, config) steps.zip(EXTENSION_DIR, EXTENSION_ZIP) steps.stash(EXTENSION_ZIP_STASH, EXTENSION_ZIP) + } } diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index c94710bc..bb4f7886 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -1,13 +1,12 @@ package ru.pulsar.jenkins.library.steps +import ru.pulsar.jenkins.library.edt.EdtCliEngineFactory import ru.pulsar.jenkins.library.IStepExecutor import ru.pulsar.jenkins.library.configuration.JobConfiguration import ru.pulsar.jenkins.library.configuration.SourceFormat import ru.pulsar.jenkins.library.ioc.ContextRegistry -import ru.pulsar.jenkins.library.utils.EDT import ru.pulsar.jenkins.library.utils.FileUtils import ru.pulsar.jenkins.library.utils.Logger -import ru.pulsar.jenkins.library.utils.VersionParser class EdtValidate implements Serializable { @@ -32,7 +31,6 @@ class EdtValidate implements Serializable { def env = steps.env() - String workspaceLocation = "$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE" String projectList if (config.sourceFormat == SourceFormat.DESIGNER) { @@ -51,31 +49,11 @@ class EdtValidate implements Serializable { projectList = "--project-list \"$projectDir\"" } - def resultFile = "$env.WORKSPACE/$RESULT_FILE" - def edtVersionForRing = EDT.ringModule(config) - Logger.println("Выполнение валидации EDT") - if (VersionParser.compare(config.edtVersion, "2024") < 0) { - - Logger.println("Версия EDT меньше 2024.1.X, для валидации используется ring") - - def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList" - steps.catchError { - steps.ringCommand(ringCommand) - } - - } else { - - Logger.println("Версия EDT больше 2024.1.X, для валидации используется 1cedtcli") + def engine = EdtCliEngineFactory.getEngine(config.edtVersion) - def edtcliCommand = "1cedtcli -data \"$workspaceLocation\" -command validate --file \"$resultFile\" $projectList" - steps.catchError { - def stdOut = steps.cmd(edtcliCommand, false, true) - Logger.println(stdOut) - } - - } + engine.edtValidate(steps, config, projectList) steps.archiveArtifacts("$DesignerToEdtFormatTransformation.WORKSPACE/.metadata/.log") steps.archiveArtifacts(RESULT_FILE) diff --git a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy index 925a3c47..4914cdf8 100644 --- a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy +++ b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy @@ -43,22 +43,4 @@ class VersionParser implements Serializable { return matcher != null && matcher.getCount() == 1 ? matcher[0][1] : "" } - static int compare(String thisVersion, String thatVersion) { - - def thisVersionParts = thisVersion.split("\\.") - def thatVersionParts = thatVersion.split("\\.") - - def minIndex = Math.min(thisVersionParts.length, thatVersionParts.length) - - for (int i = 0;i < minIndex;i++) { - - if (thisVersionParts[i].toInteger() > thatVersionParts[i].toInteger()) { - return 1 - } else if (thisVersionParts[i].toInteger() < thatVersionParts[i].toInteger()) { - return -1 - } - } - - return 0 - } } diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java index afa03ae5..3ef626cb 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/VersionParserTest.java @@ -85,34 +85,4 @@ void testConfiguration() throws IOException { assertThat(storage).isEqualTo("1.0.0.1"); } - @Test - void testVersionComparisonLessThan() { - - // given - String thisVersion = "2023.2.4"; - String thatVersion = "2023.3.1"; - - // when - int result = VersionParser.compare(thisVersion, thatVersion); - - // then - assertThat(result).isEqualTo(-1); - - } - - @Test - void testVersionComparisonEqualShort() { - - // given - String thisVersion = "2024.2.4"; - String thatVersion = "2024.2"; - - // when - int result = VersionParser.compare(thisVersion, thatVersion); - - // then - assertThat(result).isEqualTo(0); - - } - } \ No newline at end of file From 5096737ae99c2d672ab4dcb0797a0942fa146763 Mon Sep 17 00:00:00 2001 From: Dima Date: Sun, 10 Nov 2024 17:50:36 +0300 Subject: [PATCH 06/12] remove explicit type --- src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy index 767638ab..b8a3ce7c 100644 --- a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy +++ b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy @@ -4,7 +4,7 @@ import java.lang.module.ModuleDescriptor class EdtCliEngineFactory { - static IEdtCliEngine getEngine(String edtVersion) { + static getEngine(String edtVersion) { def currentVersion = ModuleDescriptor.Version.parse(edtVersion) def version2024 = ModuleDescriptor.Version.parse("2024") From 5af9ba1d58c8d4c9a1c67d34662092c6794cbe3f Mon Sep 17 00:00:00 2001 From: Dima Date: Sun, 10 Nov 2024 18:10:34 +0300 Subject: [PATCH 07/12] fix class file extension --- .../pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy | 2 +- .../edt/{IEdtCliEngine.java => IEdtCliEngine.groovy} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/ru/pulsar/jenkins/library/edt/{IEdtCliEngine.java => IEdtCliEngine.groovy} (65%) diff --git a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy index b8a3ce7c..767638ab 100644 --- a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy +++ b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy @@ -4,7 +4,7 @@ import java.lang.module.ModuleDescriptor class EdtCliEngineFactory { - static getEngine(String edtVersion) { + static IEdtCliEngine getEngine(String edtVersion) { def currentVersion = ModuleDescriptor.Version.parse(edtVersion) def version2024 = ModuleDescriptor.Version.parse("2024") diff --git a/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java b/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.groovy similarity index 65% rename from src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java rename to src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.groovy index ef498d75..d5ce6330 100644 --- a/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.java +++ b/src/ru/pulsar/jenkins/library/edt/IEdtCliEngine.groovy @@ -1,9 +1,9 @@ -package ru.pulsar.jenkins.library.edt; +package ru.pulsar.jenkins.library.edt -import ru.pulsar.jenkins.library.IStepExecutor; -import ru.pulsar.jenkins.library.configuration.JobConfiguration; +import ru.pulsar.jenkins.library.IStepExecutor +import ru.pulsar.jenkins.library.configuration.JobConfiguration -public interface IEdtCliEngine { +interface IEdtCliEngine { void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config); void edtToDesignerTransformExtensions(IStepExecutor steps, JobConfiguration config); void designerToEdtTransform(IStepExecutor steps, JobConfiguration config); From 83ee97f9741c1045e592d633cebabd46db33a6d7 Mon Sep 17 00:00:00 2001 From: Dima Date: Sun, 10 Nov 2024 18:16:36 +0300 Subject: [PATCH 08/12] fix --- .../pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy | 6 +++--- src/ru/pulsar/jenkins/library/edt/RingConverter.groovy | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy index 10869a80..fa090ca3 100644 --- a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy @@ -14,7 +14,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { @Override void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config) { - String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.WORKSPACE").getRemote() String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() @@ -34,7 +34,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { def env = steps.env() - String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.WORKSPACE").getRemote() String extensionRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.EXTENSION_DIR").getRemote() config.initInfoBaseOptions.extensions.each { @@ -59,7 +59,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { def env = steps.env() - def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") + def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE") def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") def projectName = configurationRoot.getName() diff --git a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy index 967a567a..b0abb17f 100644 --- a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy @@ -19,7 +19,7 @@ class RingConverter implements IEdtCliEngine { def edtVersionForRing = EDT.ringModule(config) def srcDir = config.srcDir - String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.WORKSPACE").getRemote() String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() String projectDir = FileUtils.getFilePath("$env.WORKSPACE/$srcDir").getRemote() String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() @@ -38,7 +38,7 @@ class RingConverter implements IEdtCliEngine { def env = steps.env() - String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.WORKSPACE").getRemote() def edtVersionForRing = EDT.ringModule(config) String extensionRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.EXTENSION_DIR").getRemote() @@ -63,7 +63,7 @@ class RingConverter implements IEdtCliEngine { def env = steps.env() - def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") + def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE") def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") def projectName = configurationRoot.getName() From d32239d2a98d4e70bddbd6f2adf4075a5586dba6 Mon Sep 17 00:00:00 2001 From: Dima Date: Sun, 10 Nov 2024 18:23:18 +0300 Subject: [PATCH 09/12] fix --- src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy | 1 - src/ru/pulsar/jenkins/library/edt/RingConverter.groovy | 1 - 2 files changed, 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy index fa090ca3..3154b66c 100644 --- a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy @@ -65,7 +65,6 @@ class NativeEdtCliConverter implements IEdtCliEngine { def projectName = configurationRoot.getName() steps.deleteDir(workspaceDir) - steps.deleteDir(configurationRoot) Logger.println("Конвертация исходников из формата конфигуратора в формат EDT с помощью 1cedtcli") diff --git a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy index b0abb17f..2ab367bb 100644 --- a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy @@ -50,7 +50,6 @@ class RingConverter implements IEdtCliEngine { Logger.println("Конвертация исходников расширения ${it.name} из формата EDT в формат Конфигуратора с помощью ring") - def projectDir = FileUtils.getFilePath("$env.WORKSPACE/${it.path}") def currentExtensionWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cfe/${it.name}") def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$currentExtensionWorkspaceDir\" --project \"$projectDir\" --configuration-files \"$extensionRoot/${it.name}\"" From 85bb6f9e4963c70cff523dfdc700f659bb7ceacc Mon Sep 17 00:00:00 2001 From: Nikita Fedkin Date: Tue, 12 Nov 2024 21:03:19 +0100 Subject: [PATCH 10/12] Update src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy index 3154b66c..8bac43fa 100644 --- a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy @@ -18,7 +18,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() - Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора с помощью ring") + Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора с помощью 1cedtcli") steps.deleteDir(configurationRoot) From 9c4fea035f7859aea47d77a9f5fee2b715612e43 Mon Sep 17 00:00:00 2001 From: Dima Date: Thu, 14 Nov 2024 14:16:56 +0300 Subject: [PATCH 11/12] fixes --- README.md | 1 + .../library/edt/EdtCliEngineFactory.groovy | 34 +++++++++++++++---- .../library/edt/NativeEdtCliConverter.groovy | 11 +++--- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 89c095ea..3a20bba0 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ 1. Для шага подготовки требуется любой агент с меткой `agent`. 1. Для запуска шага анализа SonarQube требуется агент с меткой `sonar`. 1. Для запуска шагов, работающих с EDT (валидация, трансформация формата исходников) требуется агент с меткой `edt` (если используется несколько версий EDT необходимо к метке добавить версию, например `edt@2021.3.4:x86_64`) и агент с меткой `oscript`, на котором глобально установлена библиотека [stebi](https://github.com/Stepa86/stebi) версии 1.11.1 и выше или [edt-ripper](https://github.com/bia-technologies/edt_ripper). +1. При использовании EDT версии 2024.1.0 и выше вместо ring используется 1cedtcli, который должен быть прописан в PATH на агенте. 1. Для запуска шагов, работающих с 1С (подготовка, синтаксический контроль и т.д.) требуется агент с меткой, совпадающей со значением в поле `v8version` файла конфигурации. 1. В качестве ИБ используется файловая база, создаваемая в каталоге `./build/ib`. При необходимости вы можете создать пользователей на фазе инициализации ИБ. diff --git a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy index 767638ab..02ebc8b0 100644 --- a/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy +++ b/src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy @@ -4,15 +4,37 @@ import java.lang.module.ModuleDescriptor class EdtCliEngineFactory { + private static final ModuleDescriptor.Version EDT_CLI_MIN_VERSION = ModuleDescriptor.Version.parse("2024") + + /** + * Создает движок конвертации в зависимости от версии EDT + * @param edtVersion версия EDT в формате YYYY.X.Z, YYYY.X или YYYY + * @return IEdtCliEngine подходящая реализация движка + * @throws IllegalArgumentException если версия имеет некорректный формат + */ static IEdtCliEngine getEngine(String edtVersion) { - def currentVersion = ModuleDescriptor.Version.parse(edtVersion) - def version2024 = ModuleDescriptor.Version.parse("2024") + if (edtVersion == null || edtVersion.trim().empty) { + throw new IllegalArgumentException("Версия EDT не может быть пустой") + } + + try { + def currentVersion = ModuleDescriptor.Version.parse(edtVersion) - if (currentVersion < version2024) { - return new RingConverter() - } else { - return new NativeEdtCliConverter() + return isEdtCliRequired(currentVersion) + ? new NativeEdtCliConverter() + : new RingConverter() + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Некорректный формат версии EDT: ${edtVersion}", e) } } + + /** + * Проверяет необходимость использования 1cedtcli + * @param edtVersion текущая версия EDT + * @return true если нужно использовать 1cedtcli + */ + private static boolean isEdtCliRequired (ModuleDescriptor.Version edtVersion) { + return edtVersion >= EDT_CLI_MIN_VERSION + } } diff --git a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy index 3154b66c..e48a1600 100644 --- a/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy @@ -14,16 +14,19 @@ class NativeEdtCliConverter implements IEdtCliEngine { @Override void edtToDesignerTransformConfiguration(IStepExecutor steps, JobConfiguration config) { + def env = steps.env() + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.WORKSPACE").getRemote() String projectWorkspaceDir = FileUtils.getFilePath("$workspaceDir/cf").getRemote() - String configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR").getRemote() + def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR") + String configurationRootFullPath = configurationRoot.getRemote() Logger.println("Конвертация исходников конфигурации из формата EDT в формат Конфигуратора с помощью ring") steps.deleteDir(configurationRoot) def projectName = configurationRoot.getName() - def edtcliCommand = "1cedtcli -data \"$projectWorkspaceDir\" -command export --configuration-files \"$configurationRoot\" --project-name $projectName" + def edtcliCommand = "1cedtcli -data \"$projectWorkspaceDir\" -command export --configuration-files \"$configurationRootFullPath\" --project-name \"$projectName\"" steps.cmd(edtcliCommand) @@ -48,7 +51,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { def edtcliCommand = "1cedtcli -data \"$currentExtensionWorkspaceDir\" -command export --configuration-files \"$extensionRoot/${it.name}\" --project-name ${it.name}" - steps.cmd(edtcliCommand) + steps.cmd(edtcliCommand) } @@ -68,7 +71,7 @@ class NativeEdtCliConverter implements IEdtCliEngine { Logger.println("Конвертация исходников из формата конфигуратора в формат EDT с помощью 1cedtcli") - def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name $projectName" + def edtcliCommand = "1cedtcli -data \"$workspaceDir\" -command import --configuration-files \"$configurationRoot\" --project-name \"$projectName\"" steps.cmd(edtcliCommand) From ab9ee006569cda959470535b6e90d2b7fd855d4e Mon Sep 17 00:00:00 2001 From: Dima Date: Thu, 14 Nov 2024 14:22:57 +0300 Subject: [PATCH 12/12] fix quotes --- src/ru/pulsar/jenkins/library/edt/RingConverter.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy index 2ab367bb..8a0658a9 100644 --- a/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy +++ b/src/ru/pulsar/jenkins/library/edt/RingConverter.groovy @@ -73,7 +73,7 @@ class RingConverter implements IEdtCliEngine { Logger.println("Конвертация исходников из формата конфигуратора в формат EDT с помощью ring") String edtVersionForRing = EDT.ringModule(config) - String ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $projectName --workspace-location \"$workspaceDir\"" + String ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name \"$projectName\" --workspace-location \"$workspaceDir\"" steps.ringCommand(ringCommand)