Delete

Remove a file or a directory from the DropZone.

Delete

Delete removes a file or a directory from the DropZone. Any file or directory marked as deleted will not be transferred to the target Endpoint(s) in any subsequent deployment.

delete takes the following optional named parameters:

Parameter Description
file Optional. The name of the file to be removed.
dir Optional. The name of the directory to be removed.

NOTE: A single file or dir parameter must be specified.

Example 1

Remove all files of zero length from the DropZone. If this is done in a pre-action to a Component, then no zero length file will be deployed to the Endpoint even if they have been checked out from the repository:

set filelist = ${DropZone.files};

iterate(file: $filelist) {

echo "File size is ";

echo ${file.size};

if (${file.size} = 0) {

echo "Removing file ${file.dzpath}";

delete(file: ${file.dzpath});

}

}

Example 2

Pre Action to a Component:

Remove all files with a modification time prior to the time the Component was last deployed to the Endpoint. If this removes all files, the Component will not be deployed (since there are no files left in the DropZone). This allows you to set a Component to “Deploy Always” and only push files that have been added to the Component since it was last deployed.

if (${dep.same}) {

// We're deploying the same version of Application as currently

// on the Target Environment

psloop {

// for each Endpoint in the Environment…

set dt = ${server.deptime($Component)};

if ($dt) {

// This Component has previously been deployed to

// this Endpoint. Check the files and remove any

// that predate this deployment time

set filelist = ${DropZone.files};

iterate(file: $filelist) {

if (${file.mtime} < $dt) {

echo "Removing file $file";

delete(file: $file);

}

}

}

}

}