< Previous | Next >

Lesson 2: Create a component process

Component processes are user-defined tasks that operate on components.

A component process is a succession of commands that are called steps. Steps can manipulate files, run system commands, set properties, pass information to other steps, and run programs. Steps are provided by automation plug-ins. Processes are designed with the drag-and-drop process editor where you drag plug-in steps onto the design editor and configure them as you go. Several plug-ins come with the product and others are available, which work with many different types of software. In this tutorial you use two plug-ins, both of which come with the product: FileUtils and IBM UrbanCode Deploy. A component can have any number of processes defined for it, but a component must have at least one process.

In this lesson, you create a deployment process for the helloWorld component. Later, you create an application process that uses the component process to deploy the component.

To create the component process:

  1. Define the component process:
    1. On the "Component: helloWorld" page, click the Processes tab and then click Create New Process.
    2. In the Create New Process window, type helloProcess in the Name field.
    3. In the Process Type list, select Deployment. This list has other options for processes that uninstall or configure components.
    4. Accept the default values for the other fields and click Save. The Default Working Directory field becomes the folder that the agent uses to do its work, such as downloading artifacts and creating temporary files. For the tutorial, the value becomes \agent_install\var\work\helloWorld.
    The process is listed on the Processes pane.
  2. From the list of processes, select helloProcess. The process opens in the process editor. The process editor lists plug-ins and steps. The required Start and Finish steps represent the beginning and the end of the process and are automatically placed on the design area. You add steps to the process by dragging them onto the design area and arranging them between the Start and Finish steps.
    The process design editor
  3. Add a step that removes files from the working directory. To ensure that the agent works with the most recent files, remove files that remain from previous work:
    1. In the Available Plugin Steps list, expand Utilities > FileUtils.
    2. Click and drag the Delete Files and Directories step to the process editor. The Edit Properties window opens, showing the properties for the step. Some of these properties are unique to the step and others are the same for all steps.
    3. In the Name field, specify a name, for example, Clean work space.
    4. In the Base Directory field, specify a single period (.). This value resolves to the folder that you specified as the agent working directory.
    5. In the Include field, specify an asterisk (*). This parameter instructs the agent to remove all files in the working directory.
    6. Accept the default values for the other properties and then click Save.
    The new step is displayed in the design area. Each step has two icons at the upper-right corner of the step. Click the green Edit icon to reopen the Edit Properties window where you can modify the step properties. Click the X icon to delete the step and connections to or from it.
    The new process with one step
  4. Connect the Start step to the Clean work space step. Beginning with Start, the connections between steps determines the process flow. You can define connections as you place steps, or later.
    1. Move the mouse over Start. The arrow icon is displayed, as the following figure shows. You use this icon to connect steps to one another.
      The arrow icon
    2. Click and drag the arrow icon over the Clean work space step. The connecting arrow links the two steps, as the following figure shows. The direction of the arrow defines the direction of the process flow.
      The arrow connects the first two steps
  5. Add a step to download the latest version of the component artifacts from the CodeStation repository. The Download Artifacts step is used in most deployment-type processes. This step downloads the specified version of the component artifacts to the agent's recently cleaned working directory. When you run the process, specify which version of the component artifacts to use.
    1. Under Available Plugin Steps, expand Repositories > Artifact > IBM UrbanCode Deploy and drag the Download Artifacts step to the process editor.
    2. In the Edit Properties window, accept the default values and then click Save.
    3. Draw a connection from the Clean work space step to the Download Artifacts step. Except for connections from Start, each connection has a conditional flag. The conditional flag represents the process status that is required before the connection can be followed. The connection is followed only if the originating step is complete, and the specified condition is met. The possible conditions are as follows: success, failure, or both. The default condition is success, which is represented by a green check mark, as the following figure shows. In this example, the Download Artifacts step is started only if the Clean work space step finishes with a success condition. You can change the conditional flag by clicking the icon.
      The conditional flag
  6. Add a step to create a compressed file. In this example, the compressed file contains the files that were downloaded in the previous step.
    1. Expand Utilities > FileUtils and drag a Create .zip file step to the process editor.
    2. In the Edit Properties window, specify the name Compress artifacts.
    3. In the .zip File Name field, type helloWorld.zip.
    4. In the Base Directory field, type a single period (.). The compressed file is created in the agent working directory.
      Note: If you specify the final destination directory instead of the agent working directory, the following step would be unnecessary. However, in addition to moving the file, the following step demonstrates how to use the property that you created earlier.
    5. In the Include field, type an asterisk (*). The compressed file contains all the files that were downloaded from the repository.
    6. Accept the default values in the other fields and click Save.
    7. Draw a connection from the Download Artifacts step to the Compress artifacts step.
  7. Add a step to move the artifacts. This step moves the compressed file to the target folder. For simplicity, the tutorial moves the file to a directory in the \helloWorld folder.
    1. Expand Utilities > FileUtils and drag a Move Directory step to the process editor.
    2. In the Edit Properties window, specify the name Deploy artifacts.
    3. In the Source Directory field, type a single period (.).
    4. In the Destination Directory field, type the following value: ${p:helloHome}/target. The ${p:helloHome} value refers to the property that you created earlier. The /target directory is relative to the property value. If, for example, you defined the property value as /home/user1/artifacts/shared/helloWorld, the file is moved to /home/user1/artifacts/shared/helloWorld/target. For information about using properties, see Properties.
    5. In the Include Files field, type: *.zip.
    6. Accept the default values in the other fields and click Save.
  8. Save the process by clicking the Save icon under Tools.
The complete process for the helloWolrd component looks like the following figure:
The complete process for the helloWorld component

Lesson checkpoint

In this lesson, you created component processes to deploy the helloWorld component.
You can use component processes to automate many tasks on components. Later in this tutorial, you create an application process to deploy the component.
< Previous | Next >

Feedback