Executing a CLI script or command

The exec-cli-script and exec-cli-command goals will let you start an RHQ CLI in order to execute either a script or a command.

By default, the CLI will start disconnected. You can configure both mojos to login to a remote RHQ server with the following properties:

  • login boolean - Whether to login to a remote RHQ server
  • host String - Remote RHQ server host
  • port int - Remote RHQ server port
  • username String - Authentication user name
  • password String - Authentication password

Executing a CLI script

By default, CLI script argument style is indexed. You can change this to named using the argsStyle property.

    ...
    <execution>
        <id>exec-cli-script</id>
        <phase>package</phase>
        <goals>
            <goal>exec-cli-script</goal>
        </goals>
        <configuration>
            <rhqVersion>${rhq.version}</rhqVersion>
            <scriptFile>${basedir}/src/cli-scripts/sample.js</scriptFile>
            <args>
                <arg>Maven Invoker</arg>
                <arg>${project.build.directory}/sample.js.out</arg>
            </args>
            <argsStyle>indexed</argsStyle>
        </configuration>
    </execution>
    ...

Executing a CLI command

    ...
    <execution>
        <id>exec-cli-command</id>
        <phase>package</phase>
        <goals>
            <goal>exec-cli-command</goal>
        </goals>
        <configuration>
            <rhqVersion>${rhq.version}</rhqVersion>
            <command>scriptUtil.saveBytesToFile(new java.lang.String("Hello!").getBytes(), "${project.build.directory}/cli-command.out")</command>
        </configuration>
    </execution>
    ...