Skip to content

Commit

Permalink
Рефакторинг для перехода на ringCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Smirnov committed Mar 7, 2024
1 parent 0fd8cae commit bef4a4e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/ru/pulsar/jenkins/library/steps/Cmd.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 12 additions & 4 deletions src/ru/pulsar/jenkins/library/steps/RingCommand.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}

0 comments on commit bef4a4e

Please sign in to comment.