1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2025-02-08 14:29:15 +02:00

Рефакторинг для перехода на ringCommand

This commit is contained in:
Ivan Smirnov 2024-03-07 14:24:46 +03:00
parent 0fd8cae14f
commit bef4a4ed24
5 changed files with 17 additions and 21 deletions

View File

@ -22,7 +22,7 @@ class Cmd implements Serializable {
def returnValue
if (returnStatus & returnStdout) {
return "returnStatus and returnStdout are not supported at the same time"
steps.error("returnStatus and returnStdout are not supported at the same time")
}
if (steps.isUnix()) {

View File

@ -4,7 +4,6 @@ package ru.pulsar.jenkins.library.steps
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.Constants
import ru.pulsar.jenkins.library.utils.EDT
import ru.pulsar.jenkins.library.utils.FileUtils
import ru.pulsar.jenkins.library.utils.Logger
@ -45,10 +44,7 @@ class DesignerToEdtFormatTransformation implements Serializable {
def ringCommand = "ring $edtVersionForRing workspace import --configuration-files \"$configurationRoot\" --project-name $PROJECT_NAME --workspace-location \"$workspaceDir\""
def ringOpts = [Constants.DEFAULT_RING_OPTS]
steps.withEnv(ringOpts) {
steps.ringCommand(ringCommand)
}
steps.ringCommand(ringCommand)
steps.zip(WORKSPACE, WORKSPACE_ZIP)
steps.stash(WORKSPACE_ZIP_STASH, WORKSPACE_ZIP)

View File

@ -5,7 +5,6 @@ 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.Constants
import ru.pulsar.jenkins.library.utils.EDT
import ru.pulsar.jenkins.library.utils.FileUtils
import ru.pulsar.jenkins.library.utils.Logger
@ -48,10 +47,7 @@ class EdtToDesignerFormatTransformation implements Serializable {
def ringCommand = "ring $edtVersionForRing workspace export --workspace-location \"$workspaceDir\" --project \"$projectDir\" --configuration-files \"$configurationRoot\""
def ringOpts = [Constants.DEFAULT_RING_OPTS]
steps.withEnv(ringOpts) {
steps.ringCommand(ringCommand)
}
steps.ringCommand(ringCommand)
steps.zip(CONFIGURATION_DIR, CONFIGURATION_ZIP)
steps.stash(CONFIGURATION_ZIP_STASH, CONFIGURATION_ZIP)

View File

@ -4,7 +4,6 @@ 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.Constants
import ru.pulsar.jenkins.library.utils.EDT
import ru.pulsar.jenkins.library.utils.FileUtils
import ru.pulsar.jenkins.library.utils.Logger
@ -52,11 +51,8 @@ class EdtValidate implements Serializable {
Logger.println("Выполнение валидации EDT")
def ringCommand = "ring $edtVersionForRing workspace validate --workspace-location \"$workspaceLocation\" --file \"$resultFile\" $projectList"
def ringOpts = [Constants.DEFAULT_RING_OPTS]
steps.withEnv(ringOpts) {
steps.catchError {
steps.ringCommand(ringCommand)
}
steps.catchError {
steps.ringCommand(ringCommand)
}
steps.archiveArtifacts("$DesignerToEdtFormatTransformation.WORKSPACE/.metadata/.log")

View File

@ -2,21 +2,29 @@ package ru.pulsar.jenkins.library.steps
import ru.pulsar.jenkins.library.IStepExecutor
import ru.pulsar.jenkins.library.ioc.ContextRegistry
import ru.pulsar.jenkins.library.utils.Constants
class RingCommand implements Serializable {
private String script;
private String script
private boolean returnStatus
private boolean returnStdout
RingCommand(String script) {
this.script = script
this.returnStatus = false
this.returnStdout = true
};
def run() {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
String ringMessage = steps.cmd(script, false, true)
if (ringMessage.contains("error")) {
steps.error(ringMessage)
def ringOpts = [Constants.DEFAULT_RING_OPTS]
steps.withEnv(ringOpts) {
String ringMessage = steps.cmd(script, returnStatus, returnStdout)
if (ringMessage.contains("error")) {
steps.error(ringMessage)
}
}
}
}