Exploring the Filesystem Demo Project

A more detailed look at Filesystem-Demo-41

Overview

This project contains a simple set of tasks to perform filesystem and file manipulations. To keep it simple, we are not using any Data Dictionary values at either the project or target scopes, and we have only one (Linux) target configured for localhost. This means the job run from this target will run on localhost and will not require any eternal hosts to be configured. The only prerequisites are 500Mb free space in the /tmp directory and access from the RapidDeploy server to the internet.

Project Orchestration

The Orchestration tab contains details of the environment neutral task steps that will be run on each environment configured for this project. An environment is a logical configuration on a server node.

  • Firstly, navigate to Resources-> Projects and edit the project (pencil icon on the tool menu for the Filesystem-Demo-41 project line item). 
  • Navigate to the  Orchestration  tab and view the task palette on the left hand side . We have already looked a the InitialisationTask and the FinalisationTask in the detailed look at the HELLO_WORLD_40 project, so we won't cover these again here.
  • Now let's take a look at each of the tasks in turn. 

Project Orchestration Task Palette 

  • DiskSpaceCheckTask-Check-Space-In-Tmp - This task uses the DiskSpaceCheckTask to check that there is sufficient space in the /tmp directory to accommodate the deploymant package and all of the activities we are going to perform. We have arbitrarily set this at 500Mb. When initially added to the orchestration, tasks have a default name. You can change the names of tasks to be more meaningful, after you've selected them, by clicking on the task name in edit mode and retyping the name in the box. To accept the change, click the tick mark.
    • requiredFreeSpace - The amount of free space needed.
    • directoryToCheck - The directory to check for the free space. If this directory has less free space than the required free space, then the check will fail and if failOnError is set to true, the job will fail.
  • WgetTask-Download-Zip-File-From-Internet-To-Tmp - Use the  WgetTask  to download a package from the MidVision server to the /tmp  directory. Here we download the SCRIPT_DEMO_40.zip to the temporary directory.
    • remoteUrl - The URL required to obtain the downloadable resource
    • directory - The directory on the target server to download the resource to.
    • alternateFilename - The name of the file to save, if different from the name at the remote URL
    • Additional settings: You can also set proxy server parameters and access credentials as require. Please see the parameter help text in the task. In the remainder of this exercise, we will not detail the parameters, but explanations of each parameter can be found in the documentation links below or using the help functions on the task, indicated with a ' ? '.
  • MkDirTask-Make-DemoProject-SubFolder-In-Tmp - Task to create a directory. Set the windows, unix or default path as required. Any non-existent intermediate directories in the path will also be created. Here we create a DemoProject  subfolder in /tmp  .
  • DirectoryWriteCheckTask-Check-DemoProject-Folder-Writeable -Task to check a directory is writeable. Provide the directoryToCheck. Here we make sure /tmp/DemoProject is writeable.
  • CheckFileTask-Zip-File-Is-Read-Write - Task to ensure the /tmp/SCRIPT_DEMO_40.zip is both readable and writeable.
  • MoveTask-Move-Zip-File-To-DemoProject-Folder - Task to move the zip file /tmp/SCRIPT_DEMO_40.zip into the /tmp/DemoProject folder.
  • ZipTask-Unzip-File-To-SubFolder-SCRIPT_DEMO  - Unzip the /tmp/DemoProject/SCRIPT_DEMO_40.zip. into /tmp/DemoProject/SCRIPT_DEMO
  • CopyTask-Copy-SCRIPT_DEMO-Folder_To_SCRIPT_DEMO_COPY  - Task to recursively copy the folder to a new folder.
  • PosixChmodTask-Change-Permission-To-777  - Change the permissions on the /tmp/DemoProject/SCRIPT_DEMO_COPY/midvision-deploy-orchestration.xml file.
  • AntCopyTask-Copy-Folder-With-XML-FileSet-To-SCRIPT_DEMO_COPY2  - Task to recursively copy the folder to a new folder. In this example filesetIncludes is set to **/*.xml, so that only xml files (in any folder) are copied. 
  • CheckFileTask-XML-Exists  - Check that an XML file is present in the new folder, as a way to confirm the copy was successful.
  • CheckFileTask-Log4jProperties-Not-Exists  - Check a properties file does not exist in the new folder, as a way to confirm that the filter including only XML files was successful.
  • SearchReplaceTask-Single-Entry  - Search all files with the given extensions under /tmp/DemoProject/SCRIPT_DEMO_COPY2. For each PROPERTY entry in the 'Entries' panel, any key found is replaced with the corresponding value.
  • SearchReplaceTask-Three-Entries  - Search all files with the given extensions under /tmp/DemoProject/SCRIPT_DEMO_COPY2. For each PROPERTY entry in the 'Entries' panel, any key found is replaced with the corresponding value. In this case we are replacing three values.
  • SearchReplaceTask-Three-Entries-Embedded-Key   - Search all files with the given extensions under /tmp/DemoProject/SCRIPT_DEMO_COPY2. For each PROPERTY entry in the 'Entries' panel, any key found is replaced with the corresponding value. This task demonstrates that where one key is a substring of another key, the longest key is always replaced first, to prevent a shorter key placing the value of that key in the longer key, such that the longer key would never then get replaced.
  • XpathReplaceTask   -  Search all files with the given filesetIncludes (in this case all XML files in all directories) under  /tmp/DemoProject/SCRIPT_DEMO_COPY2 . For each XPATH entry in the ' Entries ' panel, replace any xml elements matching the XPATH expression with the corresponding value.
  • ReadFileTask     - Read the file specified into a string defined by the specified outputParameter. In this case read    /tmp/DemoProject/SCRIPT_DEMO_COPY2/midvision-deploy-orchestration.xml  file into ${fileContent}
  • ContainsStringTask   - Check the string in ${fileContent} from the previous task to ensure that the expected XPATH replacement was performed in the  /tmp/DemoProject/SCRIPT_DEMO_COPY2/midvision-deploy-orchestration.xml file. The outputParameter is a boolean which will be set depending on whether the required string was found in the input string. 
  • IfTask     - Conditional task, in this case checking the outputParameter of the previous task . You can select a separate path for either true or false. In this case, if the expected string replacement was found, just continue. If false, then call the FailTask to throw an error because something went wrong with the XPATH replacement operation.
  • AntDeleteTask-Cleanup   - Remove the folder and all subfolders. This task is disabled in the orchestration, but can be enabled by clicking on the red 'X' next to the task name. Task status can be toggled for any task by clicking on the tick or cross in edit mode.

Project Targets

Now we've defined the tasks to run in each invocation of this job, let's take a look at where the job can be run. In this case we've defined one target on linux. No data dictianary items are set so the target is just used to select the target host, in this case   localhost_linux

  • Firstly, navigate to Resources-> Projects and edit the project (pencil icon on the tool menu for the SCRIPT_DEMO_40 project line item). 
  • Navigate to the  Targets tab and view the list of targets
  • You can click on the server or environment to look at its configuration. The environment is not used in this example. CLick on the server to see the configuration of the localhost_linux server.
  • Use the browser back button to return to the project panel, or alternatively click on the List Projects  button to list all the projects using this server definition and click on the Filesystem-Demo-41 link.
  • As no dictinary items are set, we do not need to explore this tab any further.

Project Packages

Now we can package up all of the internal (and external - more about this later) resources in our project into a deployment package. This is a zip/jar/tar archive containing all the project components at a point in time, versioned with a version number. You can retain this package and deploy it to any target environment at any time. This gives the ability to roll forward and back through changes whenever y

  • Firstly, navigate to Resources-> Projects and edit the project (pencil icon on the tool menu for the SCRIPT_DEMO_40 project line item). 
  • Navigate to the  Packages tab and view the list of previous packages.
  • Click  Create Package  to create a new deployment package.
  • Click the Refresh button to see that the package has been created.

Run a Deployment job

Now we can deploy the created package to the square environment.

  • Navigate to Jobs-> New Job
  • Double click on the 'Empty' project job box, and select the project you created earlier from the droplist. 
  • Select the  Target   you want to deploy from the droplist. 
  • Select the  Version  (package version) you want to deploy from the droplist. 
  • Since there is only one package, it is preselected. The latest package will always be preselected by default. 
  • Click on the  Run  button in the bottom right corner, enter a comment for this run and click and click Yes 
  • The deployment is started. Click on the Running Jobs icon in the top right corner and you see the tasks executed and job log in real time.

Further Reading

The following links will help you gain a deeper understanding of the tasks used in this project: