forked from firstBitMarksistskaya/jenkins-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1402449
commit 21e59ae
Showing
9 changed files
with
233 additions
and
184 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/ru/pulsar/jenkins/library/edt/EdtCliEngineFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
92 changes: 92 additions & 0 deletions
92
src/ru/pulsar/jenkins/library/edt/NativeEdtCliConverter.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.