Search code examples
sshconnectionteamcityrsync

Can't rsync using TeamCity


I'm using TeamCity to deploy some code files to a SiteGround website. My preferred way of doing this is to make use of rsync.

I've been able to run a successful rsync command directly on the server and have transferred files just fine. However, when I try to do the same in TeamCity using the "Command Line" runner type, it just hangs. I've added -vv and --progress which has given me a little bit more information but it just seems to sit spinning.

Here's the command I'm running:

rsync -avvz --progress --exclude-from='exclude.txt' -e 'ssh -p 1234 -i "C:\key_path"' local_folder/ username@host:/home/username/www/website_name/public_html/

When that runs, I get the following output:

Step 1/1: Command Line
    Content of C:\TeamCity\buildAgent\temp\agentTmp\custom_script3540432755549071709.cmd file: 
    @echo off
    rem This is a custom script written by TeamCity using windows-1252 charset.
    rsync -avvz --progress --exclude-from='exclude.txt' -e 'ssh -p 1234 -i "C:\key_path"' local_folder/ username@host:/home/username/www/website_name/public_html/
    Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script3540432755549071709.cmd
    in directory: C:\TeamCity\buildAgent\work\b0e622b4a054b513
    opening connection using: ssh -p 1234 -i "C:\key_path" -l username host rsync --server -vvlogDtprze.iLs . /home/username/www/website_name/public_html/

This shows during the build step in TeamCity but then nothing happens. No files have transferred to the server at all. As mentioned above, this works absolutely fine from the server - I've even tried running it from the .cmd file that TeamCity created and there are no problems whatsoever.

Here's some things I've checked:

  1. I can run the command on the server in cmd.exe
  2. I can run the command using the .cmd file that TeamCity creates
  3. I left the script to run in case it was taking a while but it never completes
  4. I've tried using relative paths in the rsync command
  5. I've checked that TeamCity is using the same user that I ran the above tests on

Solution

  • I got desperate by the end of the day and noticed that TeamCity had an update available to version 2020.2.3 (build 86002). I ran the update, ran the build and it worked as expected. I'm not 100% sure what the issue was but the update seemed to do the trick.