Using

Manipulate the context or the stack for the statements body.

Using

Using affects either the context or the stack for the statements in its body. Can be used to:

  • Set the stream that standard output and standard error will be redirected to or to receive a file read or base64encode operation.

  • Create a new DropZone for scripted checkout and deployment.

  • Push a Component onto the stack and filter _Endpoint_s.

  • Push an Application onto the stack for processing.

  • Push an Environment onto the stack for processing.

Using Stream

Using “Stream” pushes a stream object onto the stack and executes the body. Any standard output or standard error resulting from the body execution are written into the stream. The stream can then be manipulated by subsequent calls.

Example 1

Checkout a file from a repository and convert it to base64:

checkout(repository: 'example\_rep', pattern: 'demo1.zip');

using stream $configzip {

read(file: 'demo1.zip');

}

set b64=${configzip.base64encode()};

A stream object should always begin with a $ symbol. The first time a stream is referenced it is automatically created. Subsequent “using stream” statements will re-use the same stream object if it has previously been referenced.

A stream can contain binary data. Streams can be used to create files and can also receive base64decoded data.

Using DropZone

Creates a new DropZone (an area on the Endpoint on which the DeployHub Pro deployment engine is running). Typically, DropZones are created for each Component and the Component items are pulled from their associated repositories into these DropZones. The using DropZone statement creates a new DropZone and allows files within that DropZone to be created, modified and pushed to target Endpoint_s without affecting any other files in the_Component DropZones.

Example 2

Given an input file “servers.xml” that looks like this:

\<DeployHub Pro\>;

\<server name="server1" type="unix" /\>;

\<server name="server2" type="windows" /\>;

\<server name="server3" type="as400" /\>;

\</DeployHub Pro\>;

Change server2 to be of type "unix", and deploy the file:

using DropZone 'DeployHub Pro' {

checkout(repository: 'local', pattern: 'servers.xml');

modify(modifier: 'xml', file: 'servers.xml') {

set\_attribute(xpath: "/DeployHub Pro/server[@name=server2]/@type", value: "unix");

}

transfer;

}

Using Component

Pushes the named Component onto the stack and reduces Endpoint set to those containing the Endpoints on which the Component resides:


using Component 'Component1' {
echo ${Component.name};
deploy;
 }

Using Application

Pushes the named Application onto the stack. Note, during a deployment operation (or a stand-alone task executed by right-clicking an Application) the selected Application is already on the stack. You can specify “using Application” when running DMScript that is not part of a deployment activity or to place another Application onto the stack for processing.

Application names can be qualified by prepending as many domain names as is necessary to uniquely identify the Application.

Using Environment

Pushes the named Environment onto the stack and sets the Endpoint set to the Endpoint_s within the_Environment. Note, during a deployment operation (or a stand-alone task executed by right-clicking an_Environment_) the selected_Environment_is already on the stack. You can specify “using_Environment_” when running_DMScript_that is not part of a deployment activity or to place another_Environment_ onto the stack for processing.

Environment names can be qualified by prepending as many domain names as is necessary to uniquely identify the Environment.

Returna

Returns from an action or returns a value from a Function.

return; // action return expression; // Function