Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

Jenkins: Uploading File to Server via HTTP POST using Jenkins Request Plugin

I am trying to upload a Softwarefile from Jenkins to a server via Pipeline. The Server API needs the following information:

Content-Type: multipart/form-data;
 
boundary= 'boundary'

body = 
--'boundary'
Content-Disposition: form-data; name=file; filename=origFilename

????
--'boundary'--

Unfortunately the HTTP Request Plugin does not support Content-Type "multipart/form-data" (https://www.jenkins.io/doc/pipeline/steps/http_request/)

I tried to just leave out the content type (since I have the options to leave it out or giving a false one) and got 415 error code. Since I'm trying to send a .txt file and knowing that the server accepts text-files (I successfully uploaded one via Postman) I think this may results from the content-type.

Current Code:

httpRequest  httpMode: 'POST', url: "https:<host>.com/", requestBody: '--' + "<boundary>" + 'Content-Disposition: form-data; name="file";' + 'filename="JenkinsDemo.txt"' + '???' + "<boundary>" + '--'

Is there any other way to get the file uploaded to the server? Or do you have a solution for using the plugin?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...