<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
CLI deployment archive
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/aloubyansky">Alexey Loubyansky</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/docs/DOC-18945">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Sometimes installing an application and setting up an environment for it may consist of deploying multiple application archives and modifying server configurations (adding new services, adjusting some settings, etc). Doing all this by hand every time you need to deploy and undeploy the application could be a tedious task. One thing that could help here is <a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-16728">batches</a>. Another one, which was introduced specifically to make it easier to install/uninstall complex applications, is CLI deployment archive.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>A CLI deployment archive is a JAR file with <strong>.cli</strong> extension containing application archives that should be deployed and CLI script files containing commands and operations: one script file contains commands and operations that deploy the application archives and set up the environment and the other one undeploys the application archives and cleans up the environment.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Let's look at a simple example. Suppose, we have a simple CLI archive with three WAR files and two scripts</p><pre class="jive-pre"><code class="jive-code">[xxx@xxx xxx]$ jar -tf test.cli
deployment0.war
deployment1.war
deployment2.war
deploy.scr
undeploy.scr</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>deploy.scr:</p><pre class="jive-pre"><code class="jive-code">
deploy deployment0.war
deploy deployment1.war
deploy deployment2.war</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>undeploy.scr:</p><pre class="jive-pre"><code class="jive-code">
undeploy deployment0.war
undeploy deployment1.war
undeploy deployment2.war</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This archive can be deployed with a simple deploy command</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] deploy test.cli
#1 deploy deployment0.war
#2 deploy deployment1.war
#3 deploy deployment2.war
[standalone@localhost:9999 /]</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>By default, the deploy command handler will look for the <em>deploy.scr</em> script file in the archive, so unless the script is named differently, there is no need to specify the script name.</p><p>Undeploying is easy as well</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] undeploy --path=test.cli
#1 undeploy deployment0.war
#2 undeploy deployment1.war
#3 undeploy deployment2.war
[standalone@localhost:9999 /]</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Note, that you should specify the path to the archive as a value of the <em>--path</em> argument of the <em>undeploy</em> command. If you try <em>undeploy test.cli</em> it will try looking for <em>test.cli</em> among the registered deployed application archives and will fail. Only <em>deployment0.war</em>, <em>deployment1.war</em> and <em>deployment2.war</em> will be registered deployments. Argument-wise, it's a little inconsistent with the <em>deploy</em> command but, although, <em>deploy test.cli</em> is a shortcut for</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] deploy --path=test.cli
#1 deploy deployment0.war
#2 deploy deployment1.war
#3 deploy deployment2.war
[standalone@localhost:9999 /]</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In this complete form, this scenario is consistent, i.e. you use <em>--path</em> for both <em>deploy</em> and <em>undeploy</em> commands.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>As with the <em>deploy</em>, <em>undeploy</em> will look for the <em>undeploy.scr</em> in the CLI arhive to uninstall the application and clean-up the environment. If your scripts are named differently (perhaps, you have different install/uninstall scripts in the same archive) you can use the <em>--script</em> argument to specify which one you want to execute.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Let's add couple of alternative scripts to our archive.</p><pre class="jive-pre"><code class="jive-code">
[xxx@xxx xxx]$ jar -tf test.cli
deployment0.war
deployment1.war
deployment2.war
deploy.scr
undeploy.scr
install.scr
uninstall.scr</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><em>install.scr</em> deploys only two deployments out of three</p><pre class="jive-pre"><code class="jive-code">
deploy deployment0.war
deploy deployment1.war</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>And <em>uninstall.scr</em> undeploys them</p><pre class="jive-pre"><code class="jive-code">
undeploy deployment0.war
undeploy deployment1.war</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Now we can choose our non-default script to install</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] deploy --path=test.cli --script=install.scr
#1 deploy deployment0.war
#2 deploy deployment1.war
[standalone@localhost:9999 /]</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>and uninstall the applications</p><pre class="jive-pre"><code class="jive-code">
[standalone@localhost:9999 /] undeploy --path=test.cli --script=uninstall.scr
#1 undeploy deployment0.war
#2 undeploy deployment1.war
[standalone@localhost:9999 /]</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="https://community.jboss.org/docs/DOC-18945">going to Community</a></p>
        <p style="margin: 0;">Create a new document in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>