سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top