0

I want to write a method that transfer/upload file from user specified location (on local) to jenkins server. Any idea how can I so this.

Thanks,

LifeIsButifool
  • 129
  • 2
  • 12
  • Have you considered using [Parameterized Build](https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build) option? Jenkins provides functionality to upload user file to job workspace out-of-box – agg3l Oct 19 '16 at 23:21
  • Thanks agg3. I forgot to mention I have to do it using code/script – LifeIsButifool Oct 20 '16 at 19:00
  • 1
    Found this question already discussed on SO: http://stackoverflow.com/questions/13348480/how-to-upload-file-from-command-line-as-file-parameter-in-jenkins – agg3l Oct 21 '16 at 00:03
  • Thanks agg3l for your continued efforts. The post mentioned above. I think, triggers the build from local machine. I want to upload file from local machine to jenkins server on triggering jenkins job. Lets say You're logged into jenkins and you want to pull file to jenkins server from your local machine. This requires creating channel which I dont know how to do. Any idea how can I proceed? – LifeIsButifool Oct 21 '16 at 00:32
  • _That_ post is about triggering Jenkins job through remote API. Don't be confused by _http://jenkins:8080_ server name, it's a generic example name. You want to retrieve remote user-specified file by Jenkins (i.e. user specifies some URL as job parameter) ? In such case it depends on URL scheme (http://, ssh://, git:// ) – agg3l Oct 21 '16 at 00:50
  • Ok, so I want to transfer file from user local machine to jenkins server when I trigger Job. And that job has to be triggered from only web interface which means not using REST API on our local machine. – LifeIsButifool Oct 21 '16 at 00:54
  • Solutions proposed within there using `curl` access jenkins via HTTP(s) web frontend. – agg3l Oct 21 '16 at 01:03
  • I am using this: curl http://jenkins/job/$JOB_NAME/build -F file0=@PATH_TO_FILE -F json='{"parameter": [{"name":"FILE_LOCATION_AS_SET_IN_JENKINS", "file":"file0"}]}'. Error: 0curl: (26) couldn't open file. – LifeIsButifool Oct 21 '16 at 01:43

0 Answers0