Deleting files from an FTP Server?

Hi,

I'm working through a series of build steps for deploying software to a remote server.    Haved used the ftp build step to successfully copy files up to a deployment server.   This part works great.

However, I've got another scenario where I need to copy a file up (no problem there) then later delete the file that I copied up, as it's no longer needed and will be taking up valuable space on the server.   I'd like to have a build step that will delete the file from the FTP server.

I'm sure that I'm missing something obvious (usually am with this stuff) and was wondering if someone would be able to give an example of how to do this?

btw. I know what file on the ftp server needs to be removed.

1
2 comments
Avatar
Permanently deleted user

Need same thing. Did you work it out? I tried using SSH exec but 

[Step 1/2] Executing commands: echo "rm fileTo.delete" | sftp
[Step 1/2] This account is restricted by rssh. Allowed commands: sftp

0

Hi both, sorry the initial message seemed to slip through.

We don't have current support to send delete FTP commands. Our FTP Deployer simply tries to send the files specified, nothing else. What you can do in this situation, is use a script, be it ssh or a full command line script using an SSH Agent build feature (https://confluence.jetbrains.com/display/TCD10/SSH+Agent) and running a script that connects to the remote server and deletes the file, or using a command line ftp client that accepts FTP delete commands via parameters in a non-interactive manner (as any interactive command would never return, as teamcity will not interact with it)

Regarding the rssh restricted account, it seems your remote server is using rssh, while our SSH Exec tries to open a regular SSH shell, not an sftp one, which means it's going to fail. In your case, I'm afraid you will need to set up some kind of script using SSH Agent that will send the sftp commands directly from the shell.

0

Please sign in to leave a comment.