Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added "dir" and "stderr" attributes to executable dynvars, added one more example

...

Last but not least, a dynamic variable value can be assigned from the output of an external command execution.

Using a dynamic variable assignment from command output is recognized by using the attribute executable in the variable definition.

Specific attributes:

  • executable
    Absolute or relative path to the command to be launched. If the "dir" attribute is used, than relative paths are computed against the mentioned directory. The characters '.' and '..' inside the command path are resolved to a canonical path according to the operating system.
  • type := "process" | "shell" (optional, defaults to "process")
    "process" - launch the command directly without an underlying shell invocation
    "shell" - launch the command over the system shell, assuming it to be a shell script
  • dir (optional)
    Absolute or relative path to a work directory, from where the command should be launched. The characters '.' and '..' inside the directory path are resolved to a canonical path according to the operating system.
  • stderr := "true" | "false" (optional, defaults to "false")
    Whether the standard error output of the command should be used instead of the standard output.
    This can be useful for some commands which deliver certain information only as error, for instance 'java -version'..

Example 1:

Code Block
langxml
titleAssigning a dynamic variable value from the output of a command execution
<dynamicvariables>

    <variable name="hostname" checkonce="true"
              executable="hostname"
              type="process"/>

    <variable name="result.value" checkonce="true"
              executable="${INSTALL_PATH}/bin/init.sh"
              type="shell"/>

</dynamicvariables>

Example 2:

Code Block
langxml
titleAssigning a dynamic variable value from the output of a command execution
<dynamicvariables>

    <variable name="hostname="previous.java.version" checkonce="true"
              executabledir="hostname${INSTALL_PATH}"
              typeexecutable="jre/bin/java" stderr="process"/>true"
             <variable nametype="result.valueprocess" checkonceignorefailure="true"
              executable="${INSTALL_PATH}/bin/init.sh"  condition="haveInstallPath+isUpgrade">
      <arg>-version</arg>
      <regex regexp="java  type="shell"/>version[^\d]+([\d\._]+)" select="\1"/>
    </variable>

</dynamicvariables>

Filtering Values Using Regular Expressions

...