mirror of https://github.com/apache/nifi.git
NIFI-4815 - Add EL support to ExecuteProcess
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #2432
This commit is contained in:
parent
bc37015693
commit
ff95be2a11
|
@ -85,7 +85,7 @@ public class ExecuteProcess extends AbstractProcessor {
|
|||
.name("Command")
|
||||
.description("Specifies the command to be executed; if just the name of an executable is provided, it must be in the user's environment PATH.")
|
||||
.required(true)
|
||||
.expressionLanguageSupported(false)
|
||||
.expressionLanguageSupported(true)
|
||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
||||
.build();
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class ExecuteProcess extends AbstractProcessor {
|
|||
public static final PropertyDescriptor WORKING_DIR = new PropertyDescriptor.Builder()
|
||||
.name("Working Directory")
|
||||
.description("The directory to use as the current working directory when executing the command")
|
||||
.expressionLanguageSupported(false)
|
||||
.expressionLanguageSupported(true)
|
||||
.addValidator(StandardValidators.createDirectoryExistsValidator(false, true))
|
||||
.required(false)
|
||||
.build();
|
||||
|
@ -213,7 +213,7 @@ public class ExecuteProcess extends AbstractProcessor {
|
|||
|
||||
final Long batchNanos = context.getProperty(BATCH_DURATION).asTimePeriod(TimeUnit.NANOSECONDS);
|
||||
|
||||
final String command = context.getProperty(COMMAND).getValue();
|
||||
final String command = context.getProperty(COMMAND).evaluateAttributeExpressions().getValue();
|
||||
final String arguments = context.getProperty(COMMAND_ARGUMENTS).isSet()
|
||||
? context.getProperty(COMMAND_ARGUMENTS).evaluateAttributeExpressions().getValue()
|
||||
: null;
|
||||
|
@ -311,7 +311,7 @@ public class ExecuteProcess extends AbstractProcessor {
|
|||
final Boolean redirectErrorStream = context.getProperty(REDIRECT_ERROR_STREAM).asBoolean();
|
||||
|
||||
final ProcessBuilder builder = new ProcessBuilder(commandStrings);
|
||||
final String workingDirName = context.getProperty(WORKING_DIR).getValue();
|
||||
final String workingDirName = context.getProperty(WORKING_DIR).evaluateAttributeExpressions().getValue();
|
||||
if (workingDirName != null) {
|
||||
builder.directory(new File(workingDirName));
|
||||
}
|
||||
|
|
|
@ -105,7 +105,8 @@ public class TestExecuteProcess {
|
|||
@Test
|
||||
public void validateProcessInterruptOnStop() throws Exception {
|
||||
final TestRunner runner = TestRunners.newTestRunner(ExecuteProcess.class);
|
||||
runner.setProperty(ExecuteProcess.COMMAND, "ping");
|
||||
runner.setVariable("command", "ping");
|
||||
runner.setProperty(ExecuteProcess.COMMAND, "${command}");
|
||||
runner.setProperty(ExecuteProcess.COMMAND_ARGUMENTS, "nifi.apache.org");
|
||||
runner.setProperty(ExecuteProcess.BATCH_DURATION, "500 millis");
|
||||
|
||||
|
@ -127,6 +128,10 @@ public class TestExecuteProcess {
|
|||
fail();
|
||||
}
|
||||
|
||||
final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ExecuteProcess.REL_SUCCESS);
|
||||
if(!flowFiles.isEmpty()) {
|
||||
assertTrue(flowFiles.get(0).getAttribute("command").equals("ping"));
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
|
|
Loading…
Reference in New Issue