Utility: FTP Upload

Azure Pipelines | TFS 2018 | TFS 2017

Upload files to a remote machine using the File Transfer Protocol (FTP), or securely with FTPS.

Note

Build and release pipelines are called definitions in TFS 2018 and in older versions. Service connections are called service endpoints in TFS 2018 and in older versions.

Demands

None

YAML snippet

# FTP Upload
# FTP Upload
- task: FtpUpload@1
  inputs:
    #credentialsOption: 'serviceEndpoint' # Options: serviceEndpoint, inputs
    #serverEndpoint: # Required when credentialsOption == ServiceEndpoint
    #serverUrl: # Required when credentialsOption == Inputs
    #username: # Required when credentialsOption == Inputs
    #password: # Required when credentialsOption == Inputs
    rootDirectory: 
    #filePatterns: '**' 
    #remoteDirectory: '/upload/$(Build.BuildId)/' 
    #clean: false 
    #cleanContents: false # Required when clean == False
    #overwrite: true 
    #preservePaths: false 
    #trustSSL: false 

Arguments

Argument Description
FTP service connection

Select the service connection for your FTP server. To create one, click the Manage link and create a new Generic service connection, enter the FTP server URL for the server URL, e.g. ftp://server.example.com, and required credentials.

Secure connections will always be made regardless of the specified protocol (ftp:// or ftps://) if the target server supports FTPS. To allow only secure connections, use the ftps:// protocol, e.g. ftps://server.example.com. Connections to servers not supporting FTPS will fail if ftps:// is specified.

Source folder The source folder to upload files from. The default file path is relative from the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).
File patterns File paths or patterns of the files to upload. Supports multiple lines of match patterns. To upload the entire folder content recursively, specify **.
Remote directory Upload files to this directory on the remote FTP server.
Clean remote directory Recursively delete all contents of the remote directory before uploading.
Overwrite Overwrite existing files in the remote directory.
Trust server certificate Selecting this option results in the FTP server's SSL certificate being trusted with ftps://, even if it is self-signed or cannot be validated by a Certificate Authority (CA).
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A

Where can I learn more about file matching patterns?

File matching patterns reference

Q: I'm having problems. How can I troubleshoot them?

A: Try this:

  1. On the variables tab, add system.debug and set it to true. Select to allow at queue time.

  2. In the explorer tab, view your completed build and click the build step to view its output.

The control options arguments described above can also be useful when you're trying to isolate a problem.

Q: How do variables work? What variables are available for me to use in the arguments?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just a few of the variables you can use. See Variables.

Do I need an agent?

You need at least one agent to run your build or release. Get an agent.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.