mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2024-12-04 10:34:42 +02:00
Edt transformation fix (#2)
Обработка ошибки EDT: утилита ring не повышает в командной строке errorlevel, поэтому при ошибке в ринге шаг не считается проваленным. Изменил метод cmd для возможности проверить текст отработки ring и дальнейшего выявления из текста ошибки
This commit is contained in:
parent
262cd7ac24
commit
6ac28af8a0
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user