2

I have another project from which I need to copy artifacts.

However the problem I have is that it's from another server. Is there a way to do so with the copy artifact or I'll have to go through code?

Cher
  • 2,789
  • 10
  • 37
  • 64
  • I would recommend to check the [Copy Artifact Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin). – Akos Bannerth Jun 22 '15 at 20:06
  • Copy Artifact Plugin does not (AFAIK) support retries and does not output any progress to stdout while copying - this does not work well with large files/slow network in connection with jobs which timeout after x minutes without activity. Until Jenkins fixes this it could be safer to transfer large artifacts using some shell when one can retry failing operations. I know that this is probably not a problem for simple uses of Jenkins but I write this in case some one stumbles on this from a google search. – wojciii Jan 20 '17 at 08:16

4 Answers4

3

You can accomplish by either publishing your artifact and using either file transfer or secure shell.

Here is info to read upon:

Jenkins Secure Shell Plugin

Jenkins FTP Plugin

The only other possibility is to modify the ant or maven project config file.

Here is a More Reference along the same lines.

Nirmal
  • 1,229
  • 1
  • 15
  • 31
  • thanks, however I don't have the rights to modify the job I need the data from. Is there another way? I though about a script in bash, using wget. But then how do I know the files that are in the artifacts? With a REST Api? – Cher Jun 22 '15 at 20:31
  • With ssh something like following can be invoked `sshpass -p "password" scp server-ip:/dir/file`...other than FTP or SSH to get artifacts on the local box and then getting into your workspace...can you change your ant or maven file? – Nirmal Jun 22 '15 at 20:53
  • Thanks! that would work, however I'd need to know the dir and files? – Cher Jun 22 '15 at 20:57
  • so wherever you are getting the artifacts from, they should give you the server ip:port and the directory names...right? it is something that isn't under your control to modify so for just getting it, they(whosoever told you to get the files from that place) will have to give you the file path/name etc. – Nirmal Jun 22 '15 at 20:59
  • thanks a lot!! Indeed I could do it that way but I've been also told they might change the folders and file names... – Cher Jun 22 '15 at 21:04
  • sure they can change but they would have to notify all by email...1.) such change should either be made at a common file in a repository which everybody else will have to sync with 2.) such changes shouldn't be made often, in genera. – Nirmal Jun 22 '15 at 21:08
  • 1- if at all possible, have the controller of the remote job publish the artifact to common repository like nexus 2- how about the permalink option? https://documentation.cloudbees.com/docs/cje-user-guide/sec-copy-sect-creating.html – Mike D Jun 22 '15 at 23:18
3

I used a wget to fetch the file in the end, with fixed paths.

This link can help for someone not used with wget.

Using wget to recursively fetch a directory with arbitrary files in it

Community
  • 1
  • 1
Cher
  • 2,789
  • 10
  • 37
  • 64
0

For a long time I use this python script to download artifacts from Jenkins. It takes advantage of the JSON API layer available to any Jenkins job. The format of that API call is:

http://_YOUR_BUILD_HOST_/job/_JOBNAME_/lastSuccessfulBuild/api/json

Beware script depends on PyCurl.

Vitalii Elenhaupt
  • 7,146
  • 3
  • 27
  • 43
0

Publish over ssh plugin can also be used for copying the files/artifacts from one server (local/linux) to another server. It has retries option also in case there is network issue and no. of retires and timeout also can be configured.