You've already forked jenkins-lib
mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-08-25 20:09:25 +02:00
designer to edt transform with 1cedtcli
This commit is contained in:
@@ -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)
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -85,4 +85,34 @@ class VersionParserTest {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user