From 6ac28af8a09c9d19d877fe5a80fe56c938093021 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov <52702497+ivanmolodec@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:36:11 +0300 Subject: [PATCH 1/4] Edt transformation fix (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Обработка ошибки EDT: утилита ring не повышает в командной строке errorlevel, поэтому при ошибке в ринге шаг не считается проваленным. Изменил метод cmd для возможности проверить текст отработки ring и дальнейшего выявления из текста ошибки --- .../pulsar/jenkins/library/IStepExecutor.groovy | 10 ++++++---- .../pulsar/jenkins/library/StepExecutor.groovy | 12 ++++++------ src/ru/pulsar/jenkins/library/steps/Cmd.groovy | 16 +++++++++++----- .../DesignerToEdtFormatTransformation.groovy | 7 +++++-- vars/cmd.groovy | 4 ++-- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 4e15fe6f..b71d0ffb 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -12,9 +12,9 @@ interface IStepExecutor { boolean isUnix() - int sh(String script, boolean returnStatus, String encoding) + def sh(String script, boolean returnStatus, boolean returnStdout, String encoding) - int bat(String script, boolean returnStatus, String encoding) + def bat(String script, boolean returnStatus, boolean returnStdout, String encoding) String libraryResource(String path) @@ -30,9 +30,11 @@ interface IStepExecutor { void echo(message) - int cmd(String script, boolean returnStatus) + def cmd(String script, boolean returnStatus, boolean returnStdout) - int cmd(String script) + def cmd(String script, boolean returnStatus) + + def cmd(String script) void tool(String toolName) diff --git a/src/ru/pulsar/jenkins/library/StepExecutor.groovy b/src/ru/pulsar/jenkins/library/StepExecutor.groovy index 59030cfa..e02585fa 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -23,13 +23,13 @@ class StepExecutor implements IStepExecutor { } @Override - int sh(String script, boolean returnStatus, String encoding) { - steps.sh script: script, returnStatus: returnStatus, encoding: encoding + def sh(String script, boolean returnStatus, boolean returnStdout, String encoding) { + steps.sh script: script, returnStatus: returnStatus, returnStdout: returnStdout, encoding: encoding } @Override - int bat(String script, boolean returnStatus, String encoding) { - steps.bat script: script, returnStatus: returnStatus, encoding: encoding + def bat(String script, boolean returnStatus, boolean returnStdout, String encoding) { + steps.bat script: script, returnStatus: returnStatus, returnStdout: returnStdout, encoding: encoding } @Override @@ -58,8 +58,8 @@ class StepExecutor implements IStepExecutor { } @Override - int cmd(String script, boolean returnStatus = false) { - return steps.cmd(script, returnStatus) + def cmd(String script, boolean returnStatus = false, boolean returnStdout = false) { + return steps.cmd(script, returnStatus, returnStdout) } @Override diff --git a/src/ru/pulsar/jenkins/library/steps/Cmd.groovy b/src/ru/pulsar/jenkins/library/steps/Cmd.groovy index f2037522..15ea4395 100644 --- a/src/ru/pulsar/jenkins/library/steps/Cmd.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Cmd.groovy @@ -7,22 +7,28 @@ class Cmd implements Serializable { private String script; private boolean returnStatus + private boolean returnStdout private String encoding = 'UTF-8' - Cmd(String script, boolean returnStatus = false) { + Cmd(String script, boolean returnStatus = false, boolean returnStdout = false) { this.script = script this.returnStatus = returnStatus + this.returnStdout = returnStdout }; - int run() { + def run() { IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() - int returnValue + def returnValue + + if (returnStatus & returnStdout) { + return "returnStatus and returnStdout are not supported at the same time" + } if (steps.isUnix()) { - returnValue = steps.sh("$script", returnStatus, encoding) + returnValue = steps.sh("$script", returnStatus, returnStdout, encoding) } else { - returnValue = steps.bat("chcp 65001 > nul \n$script", returnStatus, encoding) + returnValue = steps.bat("chcp 65001 > nul \n$script", returnStatus, returnStdout, encoding) } return returnValue diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index 8ff00731..d06ca93e 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -34,7 +34,7 @@ class DesignerToEdtFormatTransformation implements Serializable { def env = steps.env(); - def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") + String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") def edtVersionForRing = EDT.ringModule(config) @@ -47,7 +47,10 @@ class DesignerToEdtFormatTransformation implements Serializable { def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { - steps.cmd(ringCommand) + String ringMessage = steps.cmd(ringCommand, false, true) + if (ringMessage.contains("error")) { + steps.error(ringMessage) + } } steps.zip(WORKSPACE, WORKSPACE_ZIP) diff --git a/vars/cmd.groovy b/vars/cmd.groovy index 692b019e..b882092c 100644 --- a/vars/cmd.groovy +++ b/vars/cmd.groovy @@ -1,9 +1,9 @@ import ru.pulsar.jenkins.library.steps.Cmd import ru.pulsar.jenkins.library.ioc.ContextRegistry -int call(String script, boolean returnStatus = false) { +int call(String script, boolean returnStatus = false, boolean returnStdout = false ) { ContextRegistry.registerDefaultContext(this) - Cmd cmd = new Cmd(script, returnStatus) + Cmd cmd = new Cmd(script, returnStatus, returnStdout) return cmd.run() } From d73b9a97c940c5ee6a913ca1a5ad1ccf3f309d63 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Wed, 6 Mar 2024 18:29:38 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=88=D0=B0=D0=B3=D0=B0=20ringCommand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/IStepExecutor.groovy | 2 ++ .../jenkins/library/StepExecutor.groovy | 5 ++++ .../DesignerToEdtFormatTransformation.groovy | 7 ++--- .../jenkins/library/steps/RingCommand.groovy | 22 +++++++++++++++ .../pulsar/jenkins/library/steps/CmdTest.java | 27 ++++++++++--------- vars/cmd.groovy | 2 +- vars/ringCommand.groovy | 9 +++++++ 7 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 src/ru/pulsar/jenkins/library/steps/RingCommand.groovy create mode 100644 vars/ringCommand.groovy diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index b71d0ffb..e9f9cb50 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -36,6 +36,8 @@ interface IStepExecutor { def cmd(String script) + def ringCommand(String script) + void tool(String toolName) def withCredentials(List bindings, Closure body) diff --git a/src/ru/pulsar/jenkins/library/StepExecutor.groovy b/src/ru/pulsar/jenkins/library/StepExecutor.groovy index e02585fa..e8ffe04f 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -62,6 +62,11 @@ class StepExecutor implements IStepExecutor { return steps.cmd(script, returnStatus, returnStdout) } + @Override + def ringCommand(String script) { + return steps.ringCommand(script) + } + @Override void tool(String toolName) { steps.tool toolName diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index d06ca93e..e6f62561 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -34,7 +34,7 @@ class DesignerToEdtFormatTransformation implements Serializable { def env = steps.env(); - String workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE").getRemote() + def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE/$WORKSPACE") def srcDir = config.srcDir def configurationRoot = FileUtils.getFilePath("$env.WORKSPACE/$srcDir") def edtVersionForRing = EDT.ringModule(config) @@ -47,10 +47,7 @@ class DesignerToEdtFormatTransformation implements Serializable { def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { - String ringMessage = steps.cmd(ringCommand, false, true) - if (ringMessage.contains("error")) { - steps.error(ringMessage) - } + steps.ringCommand(ringCommand) } steps.zip(WORKSPACE, WORKSPACE_ZIP) diff --git a/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy b/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy new file mode 100644 index 00000000..d58c777d --- /dev/null +++ b/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy @@ -0,0 +1,22 @@ +package ru.pulsar.jenkins.library.steps + +import ru.pulsar.jenkins.library.IStepExecutor +import ru.pulsar.jenkins.library.ioc.ContextRegistry + +class RingCommand implements Serializable { + + private String script; + + RingCommand(String script) { + this.script = script + }; + + def run() { + IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() + + String ringMessage = steps.cmd(script, false, true) + if (ringMessage.contains("error")) { + steps.error(ringMessage) + } + } +} diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/steps/CmdTest.java b/test/unit/groovy/ru/pulsar/jenkins/library/steps/CmdTest.java index 4d605480..a5518494 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/steps/CmdTest.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/steps/CmdTest.java @@ -29,14 +29,17 @@ void runOk() { final String script = "echo hello"; Cmd cmd = new Cmd(script); + when(steps.bat(anyString(), anyBoolean(), anyBoolean(), anyString())).thenReturn(0); + when(steps.sh(anyString(), anyBoolean(), anyBoolean(), anyString())).thenReturn(0); + // when - int run = cmd.run(); + Object run = cmd.run(); // then verify(steps).isUnix(); assertThat(steps).satisfiesAnyOf( - steps -> verify(steps).bat(contains(script), eq(false), anyString()), - steps -> verify(steps).sh(contains(script), eq(false), anyString()) + steps -> verify(steps).bat(contains(script), eq(false), eq(false), anyString()), + steps -> verify(steps).sh(contains(script), eq(false), eq(false), anyString()) ); assertThat(run).isEqualTo(0); @@ -49,8 +52,8 @@ void runFailNoReturn() { Cmd cmd = new Cmd(script); String thrownText = "failed"; - when(steps.bat(anyString(), anyBoolean(), anyString())).thenThrow(new Error(thrownText)); - when(steps.sh(anyString(), anyBoolean(), anyString())).thenThrow(new Error(thrownText)); + when(steps.bat(anyString(), anyBoolean(), anyBoolean(), anyString())).thenThrow(new Error(thrownText)); + when(steps.sh(anyString(), anyBoolean(), anyBoolean(), anyString())).thenThrow(new Error(thrownText)); // when Throwable thrown = catchThrowable(cmd::run); @@ -59,8 +62,8 @@ void runFailNoReturn() { // then verify(steps).isUnix(); assertThat(steps).satisfiesAnyOf( - steps -> verify(steps).bat(contains(script), eq(false), anyString()), - steps -> verify(steps).sh(contains(script), eq(false), anyString()) + steps -> verify(steps).bat(contains(script), eq(false), eq(false), anyString()), + steps -> verify(steps).sh(contains(script), eq(false), eq(false), anyString()) ); } @@ -70,17 +73,17 @@ void runPassAndReturn() { final String script = "false"; Cmd cmd = new Cmd(script, true); - when(steps.bat(anyString(), anyBoolean(), anyString())).thenReturn(1); - when(steps.sh(anyString(), anyBoolean(), anyString())).thenReturn(1); + when(steps.bat(anyString(), anyBoolean(), anyBoolean(), anyString())).thenReturn(1); + when(steps.sh(anyString(), anyBoolean(), anyBoolean(), anyString())).thenReturn(1); // when - int run = cmd.run(); + Object run = cmd.run(); // then verify(steps).isUnix(); assertThat(steps).satisfiesAnyOf( - steps -> verify(steps).bat(contains(script), eq(true), anyString()), - steps -> verify(steps).sh(contains(script), eq(true), anyString()) + steps -> verify(steps).bat(contains(script), eq(true), eq(false), anyString()), + steps -> verify(steps).sh(contains(script), eq(true), eq(false), anyString()) ); assertThat(run).isEqualTo(1); diff --git a/vars/cmd.groovy b/vars/cmd.groovy index b882092c..810dcb4c 100644 --- a/vars/cmd.groovy +++ b/vars/cmd.groovy @@ -1,7 +1,7 @@ import ru.pulsar.jenkins.library.steps.Cmd import ru.pulsar.jenkins.library.ioc.ContextRegistry -int call(String script, boolean returnStatus = false, boolean returnStdout = false ) { +def call(String script, boolean returnStatus = false, boolean returnStdout = false ) { ContextRegistry.registerDefaultContext(this) Cmd cmd = new Cmd(script, returnStatus, returnStdout) diff --git a/vars/ringCommand.groovy b/vars/ringCommand.groovy new file mode 100644 index 00000000..bc646c0b --- /dev/null +++ b/vars/ringCommand.groovy @@ -0,0 +1,9 @@ +import ru.pulsar.jenkins.library.ioc.ContextRegistry +import ru.pulsar.jenkins.library.steps.RingCommand + +def call(String script ) { + ContextRegistry.registerDefaultContext(this) + + RingCommand ringCommand = new RingCommand(script) + return ringCommand.run() +} \ No newline at end of file From 0fd8cae14fac9849b4ce9442f16dcf3275569ec2 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Wed, 6 Mar 2024 18:57:20 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A1=D0=BC=D0=B5=D0=BD=D0=B0=20=D1=88?= =?UTF-8?q?=D0=B0=D0=B3=D0=B0=20cmd=20=D0=BD=D0=B0=20ringCommand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/steps/EdtToDesignerFormatTransformation.groovy | 2 +- src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index f80acf22..315d7974 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -50,7 +50,7 @@ class EdtToDesignerFormatTransformation implements Serializable { def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { - steps.cmd(ringCommand) + steps.ringCommand(ringCommand) } steps.zip(CONFIGURATION_DIR, CONFIGURATION_ZIP) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index c24f812a..1c225fbb 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -55,7 +55,7 @@ class EdtValidate implements Serializable { def ringOpts = [Constants.DEFAULT_RING_OPTS] steps.withEnv(ringOpts) { steps.catchError { - steps.cmd(ringCommand) + steps.ringCommand(ringCommand) } } From bef4a4ed240c8ad88b031b14c3000528774652b5 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Thu, 7 Mar 2024 14:24:46 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0=20=D0=BD=D0=B0=20ringComma?= =?UTF-8?q?nd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/steps/Cmd.groovy | 2 +- .../DesignerToEdtFormatTransformation.groovy | 6 +----- .../EdtToDesignerFormatTransformation.groovy | 6 +----- .../jenkins/library/steps/EdtValidate.groovy | 8 ++------ .../jenkins/library/steps/RingCommand.groovy | 16 ++++++++++++---- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/steps/Cmd.groovy b/src/ru/pulsar/jenkins/library/steps/Cmd.groovy index 15ea4395..ead109c3 100644 --- a/src/ru/pulsar/jenkins/library/steps/Cmd.groovy +++ b/src/ru/pulsar/jenkins/library/steps/Cmd.groovy @@ -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()) { diff --git a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy index e6f62561..f678d0cf 100644 --- a/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/DesignerToEdtFormatTransformation.groovy @@ -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) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy index 315d7974..2dfa3908 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtToDesignerFormatTransformation.groovy @@ -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) diff --git a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy index 1c225fbb..f766b9e0 100644 --- a/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy +++ b/src/ru/pulsar/jenkins/library/steps/EdtValidate.groovy @@ -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") diff --git a/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy b/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy index d58c777d..53617302 100644 --- a/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy +++ b/src/ru/pulsar/jenkins/library/steps/RingCommand.groovy @@ -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) + } } } }