The Ftp activity can be use used to interact with an ftp site while running a team build. The Ftp activity can perform the following actions on an ftp site

  • Create Directory
  • Delete Directory
  • Delete Files
  • Download Files
  • Upload Files

Before you can make use of any of the TFS community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the ALM Rangers build guide or in the StyleCop page of this wiki. This page assumes the Ftp activity is available in the developers build process workflow toolbox. Hence we are able to build the workflow shown below

 

Configuring the activity

To use the Ftp activity activity, simply drag and drop it on the build process template. Once dropped, set the appropriate values for the properties required and if all the information is correct, the activity will be able to do the required task on your ftp server. Regardless of the ftp action, the following two properties are required and must be set

  • Action: Must be set to one possible values of FTPAction enumeration.
  • Host: Must be set to the host name of the ftp site.

To illustrate the use of the activity, we take a a very simple scenario that all files produced by the team build should be uploaded to an ftp site. Moreover, we also require that the files of each build should be created in a separate directory.

To start with, we need to take drop a sequence activity at an appropriate location in the build template. I chose to do it just above the “Check In Gated Changes for CheckInShelveset Builds”.

Sequence1

The next step is to drop the activities to find files, create directory and upload files. My final “Upload Drop Files to Ftp” looks as follows

Unplaod Drop Files to Ftp

 

Note that in the workflow I am using the FindMatchingFile activity, which looks for all files in the drop location and put the result in a variable “DropFiles”,  of type IEnumarable<string>.

Next the workflow checks if there are any files in the drops folder, if there are it will

First create a directory on the FTP site using the Ftp activity with action “FtpAction.CreateDirectory” using the name of the build. The value of all properties for this activity are shown below

FtpCreateDirectory

The last step is to upload all files. The workflow has another FTP activity with action set to “FtpAction.UploadFiles”, passing in the enumeration “DropFiles”. The value of all properties of this activity are shown below.

Ftp Upload Files

 

And that is it. At the end of the sequence execution everything in the root of drop folder will be uploaded to the Ftp site provided.

 

Running the Activity

When your run the build workflow, you should see the Ftp activity being executed and the files in the drop location being uploaded to the ftp directory.

successfulbuild

Last edited Jul 18, 2013 at 5:02 PM by hamid_shahid, version 2

Comments

mikeFourie Jul 19, 2013 at 1:12 PM 
Awesome documentation! Thanks Hamid.

Mike