Deploy: Copy Files Over SSH

Last Update: 5/11/2017

Team Services | TFS 2017 | Previous versions: XAML Build, Release

Copy files from source folder to target folder on a remote machine over SSH.

This task allows you to connect to a remote machine using SSH and copy files matching a set of minimatch patterns from specified source folder to target folder on the remote machine. Supported protocols for file transfer are SFTP and SCP via SFTP.

Prerequisites

  • The task supports use of an SSH key pair to connect to the remote machine(s).
  • The public key must be pre-installed or copied to the remote machine(s).

Arguments

Argument Description
SSH endpoint The name of an SSH service endpoint containing connection details for the remote machine.
- The hostname or IP address of the remote machine, the port number, and the user name are required to create an SSH endpoint.
- The private key and the passphrase must be specified for authentication.
- A password can be used to authenticate to remote Linux machines, but this is not supported for Mac or OSX systems.
Source folder The source folder for the files to copy to the remote machine. If omitted, the root of the repository is used. Names containing wildcards such as *.zip are not supported. Use variables if files are not in the repository. Example: $(Agent.BuildDirectory)
Contents File paths to include as part of the copy. Supports multiple lines of minimatch patterns. Default is ** which includes all files (including sub folders) under the source folder.
- Example: **/*.jar \n **/*.war includes all jar and war files (including sub folders) under the source folder.
- Example: ** \n !**/*.xml includes all files (including sub folders) under the source folder but excludes xml files.
Target folder Target folder on the remote machine to where files will be copied. Example: /home/user/MySite
Advanced - Clean target folder If this option is selected, all existing files in the target folder will be deleted before copying.
Advanced - Overwrite If this option is selected (the default), existing files in the target folder will be replaced.
Advanced - Flatten folders If this option is selected, the folder structure is not preserved and all the files will be copied into the specified target folder on the remote machine.
Control options See Control options

See also

Q&A

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 queue and I can't queue my build or release. How do I fix this?

See queues.

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

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.

Help and support