根据组件进程返回的结果,我想将(通过"switch.variable")应用程序转换为3种不同的方式。组件进程包含shell (bash)脚本,它可以返回字符串如下:
然后,在同一个组件过程中,我希望使用post处理bash脚本的重新结果,如下所示:
if (properties.get("exitCode") != 0) {
properties.put('Status', 'Failure');
properties.remove("switch.variable")
commandOut.println("Error")
} else {
properties.put('Status', 'Success');
scanner.register("any text", function (lineNumber, line) {
if (line.contains("DIFF")) {
properties.put("switch.variable", "DIFF")
} else if (line.contains("NO_DIFF")) {
properties.put("switch.variable", "NO_DIFF")
}
commandOut.println(properties.get("switch.variable"));
});
scanner.scan();
}你能帮我写适当的后记吗?
发布于 2018-04-12 06:31:58
假设组件进程中有一个名为“shell”的Shell脚本框,如下所示:
echo 'some text: DIFF'对于此框,您应该添加一个后处理脚本,如下所示:
if( properties.get("exitCode") != 0 ){
properties.put('Status', 'Failure');
}
else {
properties.put('Status', 'Success');
var regex = "some text";
scanner.register(regex, function(lineNumber,line){
var foo = line.substring(line.lastIndexOf(':')+1).trim();
// The ':' is the symbol after which the payload value starts.
properties.put("Lorem", foo );
});
scanner.scan();然后,在名为“shell”的Shell脚本框后面放置一个“switch”框。在该开关的属性名称中,放置Shell\Lorem。
从这里开始,您可以通过使用所需的值(如DIFF、NO_DIFF、default )绘制箭头来分支您的开关情况。默认箭头将覆盖意外情况。此外,对于Shell box失败,您可能还有其他一些逻辑。它将需要发出带有红色标志的箭头。
https://stackoverflow.com/questions/49771976
复制相似问题