FTP Upload task

Azure Pipelines | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

Use this task to upload files to a remote machine using the File Transfer Protocol (FTP), or securely with FTPS.

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Demands

None

YAML snippet

# FTP upload
# Upload files using FTP
- task: FtpUpload@2
  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
    #preservePaths: false 
    #trustSSL: false 

Arguments

Argument Description
credsType
Authentication Method
(Required) Use FTP service connection or enter connection credentials
Default value: serviceEndpoint
Argument aliases: credentialsOption
serverEndpoint
FTP Service Connection
(Required) 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, Example, 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. For example, ftps://server.example.com. Connections to servers not supporting FTPS will fail if ftps:// is specified.
serverUrl
Server URL
(Required)
username
Username
(Required)
password
Password
(Required)
rootFolder
Root folder
(Required) The source folder to upload files from
Argument aliases: rootDirectory
filePatterns
File patterns
(Required) File paths or patterns of the files to upload. Supports multiple lines of minimatch patterns. More Information.
Default value: **
remotePath
Remote directory
(Required) Upload files to this directory on the remote FTP server.
Default value: /upload/$(Build.BuildId)/
Argument aliases: remoteDirectory
enableUtf8
Enable UTF8 support
(Optional) Enables UTF-8 support for the FTP connection ('OPTS UTF8 ON')
Default value: false
clean
Delete remote directory
(Required) Delete the remote directory including its contents before uploading
Default value: false
cleanContents
Clear remote directory contents
(Required) Recursively delete all contents of the remote directory before uploading. The existing directory will not be deleted. For better performance, consider using Delete remote directory instead
Default value: false
preservePaths
Preserve file paths
(Required) If selected, the relative local directory structure is recreated under the remote directory where files are uploaded. Otherwise, files are uploaded directly to the remote directory without creating additional subdirectories.
For example, suppose your source folder is: /home/user/source/ and contains the file: foo/bar/foobar.txt, and your remote directory is: /uploads/.
If selected, the file is uploaded to: /uploads/foo/bar/foobar.txt. Otherwise, to: /uploads/foobar.txt
Default value: false
trustSSL
Trust server certificate
(Required) 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).
Default value: false
customCmds
FTP Commands
(Optional) Optional FTP Commands that will be sent to the remote FTP server upon connection

Open source

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

FAQ

Where can I learn more about file matching patterns?

File matching patterns reference

Q: I'm having issues with publishing my artifacts. How can I view the detailed logs?

To enable detailed logs for your pipeline:

  1. Edit your pipeline and select Variables
  2. Add a new variable with the name System.Debug and value true
  3. Save

Q: Which variables are available to me?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just few of the variables you can use in your pipeline. Variables are available as expressions or scripts.

See Define variables, predefined variables, and Classic release and artifacts variables to learn about the different types of variables.

Do I need an agent?

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

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

See Troubleshoot Build and Release.

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.

My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Environment variables for more details.

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.