4

My provider currently only provides FTPS as a means of uploading files to the server.

Now I want to publish files from Jenkins to that server. I can access the server using an FTP client that supports FTPS but neither of the FTP-Publisher plugins, seem to be able to publish using FTPS.

The only reference for FTPS and Jenkins that I found was this open bug.

I know that SSH would be a good option, but since my hosting provider does not support this I wonder how I can efficiently upload files to my server through jenkins.

My jenkins server runs on OSX.

Update: According to my own answer below I tried CURL but got a generic error:

curl -v -T index.html ftps://myusername:mypassword@myserver.com:21/www/
  • Adding handle: conn: 0x7fa9d500cc00
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
  • Conn 0 (0x7fa9d500cc00) send_pipe: 1, recv_pipe: 0

    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* 
    

    About to connect() to myserver.com port 21 (#0)

  • Trying xx.xx.xx.xx...
  • Connected to myserver.com (xx.xx.xx.xx) port 21 (#0)
  • Unknown SSL protocol error in connection to myserver.com:-9800
  • Closing connection 0

curl: (35) Unknown SSL protocol error in connection to myserver.com:-9800

Besi
  • 22,579
  • 24
  • 131
  • 223

2 Answers2

4

There are currently no Jenkins plugins that will handle FTPS (FTP over SSL). Instead the cURL program is capable of uploading with FTPS.

First check that cURL is installed on the Jenkins host.

On a linux environment try the command:

which curl

Now ensure that cURL is in the path for the Jenkins user account. Alternatively fully qualify the path to cURL.

Now using a post build step, task, or with the promoted builds plugin add a shell script that contains the following:

FILEPATH=$WORKSPACE/path/to/some/file
REMOTEPATH=/new/path/for/file
curl -T $FILEPATH -u username:password ftps://myserver.com$REMOTEPATH

Correct the $FILEPATH and $REMOTEPATH to reflect the environment.

Example:

FILEPATH=$WORKSPACE/index.html
REMOTEPATH=/www/index.html

If a self signed certificate is in use on the remote host then cURL needs to skip verification. This is done with the -k parameter.

curl -T $FILEPATH -u username:password -k ftps://myserver.com$REMOTEPATH
Dustin Kingen
  • 20,677
  • 7
  • 52
  • 92
1

One way of uploading might be to do this via CURL, which is not the best of options since I would rather use a Jenkins Plugin, but at least this would allow me to do it for the time being.

From the Curl docs

UPLOADING

FTP / FTPS / SFTP / SCP

Upload all data on stdin to a specified server:

curl -T - ftp://ftp.upload.com/myfile

Upload data from a specified file, login with user and password:

curl -T uploadfile -u user:passwd ftp://ftp.upload.com/myfile

Upload a local file to the remote site, and use the local file name at the remote site too:

curl -T uploadfile -u user:passwd ftp://ftp.upload.com/

Upload a local file to get appended to the remote file:

curl -T localfile -a ftp://ftp.upload.com/remotefile

Note that using FTPS:// as prefix is the "implicit" way as described in the standards while the recommended "explicit" way is done by using FTP:// and the --ftp-ssl option.

Besi
  • 22,579
  • 24
  • 131
  • 223
  • I'm running into the same issue with the requirement for FTPS. Also if Jenkins doesn't find the curl command make sure it is installed on the box and in the path. If the path cannot be modified then fully qualify the path (e.g. `/usr/bin/curl` instead of `curl`). – Dustin Kingen Jun 05 '14 at 18:52
  • @Romoku curl does not work for some strange reason, see my update in the question. – Besi Jun 05 '14 at 20:16
  • 2
    It looks like you're using the username and passord in the url. Try `curl -T index.html -u username:password ftps://myserver.com/www/index.html`. If you're using a self signed certificate then add `-k` to bypass verification. – Dustin Kingen Jun 05 '14 at 21:35
  • 1
    @Romoku You're right. This solved the problem. I was not aware of the fact that my self-signed certificate is being used. You may add your comment as an answer, which I will accept if you like. – Besi Jun 06 '14 at 05:28