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 Endpoints.
  • 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: 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 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 Endpoints without affecting any other files in the Component DropZones.


Example: Given an input file "servers.xml" that looks like this:


<deployhub>

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

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

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

</deployhub>


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


 using DropZone 'DeployHub' {

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

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

      set_attribute(xpath: "/deployhub/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 Endpoints 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.


Return

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


return;                        // action
return expression;        // Function