Skip to content

Commit

Permalink
designer to edt transform with 1cedtcli
Browse files Browse the repository at this point in the history
  • Loading branch information
ovcharenko-di committed Nov 9, 2024
1 parent 7a09d2b commit a76fc26
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions src/ru/pulsar/jenkins/library/utils/VersionParser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

}

0 comments on commit a76fc26

Please sign in to comment.