]
Alexey Loubyansky updated WFLY-3662:
------------------------------------
Git Pull Request:
CLI: non-batchable commands appearing in control flow statements
executed regardless of condition
-------------------------------------------------------------------------------------------------
Key: WFLY-3662
URL:
https://issues.jboss.org/browse/WFLY-3662
Project: WildFly
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: CLI
Affects Versions: 8.1.0.Final
Reporter: Stanley Hillner
Assignee: Alexey Loubyansky
Priority: Critical
Labels: cli, command, command-line, script
Fix For: 9.0.0.Beta1
The CLI control flows, such as if-then-else, are not working for CLI commands, such as
echo or module. Using commands in control flows results in the strange behavior that these
commands are executed in each case without respecting to what the if-statement evaluated.
I am trying to customize a fresh wildfly server with some modules and settings for our
development process. I decided to add modules using a CLI script that gets executed by
maven, but when the script declares the following the module command in the 'then'
block is executed in each case:
{noformat}
if (outcome == failed) of
/core-service=module-loading:list-resource-loader-paths(module=oracle.jdbcaq)
module add --name=oracle.jdbcaq ...
end-if
...
{noformat}
I've also verified this behavior with another structure that just checks a property
and echos something and both echos were executed:
{noformat}
/system-property=x:add(value=123)
if (result == 123) of /system-property=x:read-attribute(name=value)
echo "If block"
/system-property=x:read-attribute(name=value)
else
echo "Else block"
/system-property=x:read-attribute(name=value)
end-if
{noformat}
The next thing is that if you just put echos into the if and else blocks, the CLI
processor complains about an empty if-block. Try this one:
{noformat}
/system-property=x:add(value=123)
if (result == 123) of /system-property=x:read-attribute(name=value)
echo "If block"
else
echo "Else block"
end-if
{noformat}
This behavior has also been observed by other users (see the forum reference) and for me
it is critical to our setup since the only alternative would be copying modules manually
to the modules folder. Furthermore, there might be other commands required for us to adapt
the standalone configuration that need to be nested in an if-statement.