POSTing zip file using httpRequest in Jenkinsfile

3,672 views
Skip to first unread message

Christopher Burke

unread,
Jan 30, 2017, 4:04:13 PM1/30/17
to Jenkins Users
Hey everyone

   Part of my build pipeline requires that I publish a zip file to a server, so I'm trying the following:

response = httpRequest httpMode: 'POST', contentType: 'APPLICATION_OCTETSTREAM', body:"...", url: "${urlForPublish}"

   I'm not sure how to specify the body correctly, though. Could anyone point me to an example or offer any suggestions? In the meantime, I've worked around this by using curl, but it seems like using the httpRequest step would be preferable.

   Thanks,

   --- Chris


Indra Gunawan (ingunawa)

unread,
Jan 30, 2017, 4:33:30 PM1/30/17
to jenkins...@googlegroups.com

Stackoverflow is your friend : http://stackoverflow.com/questions/37945370/how-to-post-json-data-in-body-with-jenkins-http-request-plugin-and-pipeline

You have http-request-plugin installed on your Jenkins?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/43b61030-2d2c-42a9-9170-de718a796f6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Burke

unread,
Jan 31, 2017, 9:55:26 AM1/31/17
to Jenkins Users
Are you referring to the bug that was identified in a comment on that stackoverflow question? If so, it has been resolved so I assume I'm now able to use the requestBody. I'm not sure what other information in that question is pertinent as I am attmepting to read a zip file and that question relates to JSON.

That being said, I do have the http-request-plugin installed and realize I had a typo in the step I included in my first email.

    response = httpRequest httpMode: 'POST', contentType: 'APPLICATION_OCTETSTREAM', requestBody:???, url: "${urlForPublish}"

I am not sure how to read the contents of my zip file and supply them as the value for requestBody.

Guillaume Chorn

unread,
Oct 11, 2017, 2:52:09 PM10/11/17
to Jenkins Users
Christopher,

Did you ever find an answer to your question? I am trying to do the exact same thing and getting nowhere. Let me know.

Thanks,
Guillaume

prasad venkata ramasatya Nandagiri

unread,
May 18, 2018, 1:21:20 PM5/18/18
to Jenkins Users
Please let me know, if the issue had been resolved.

prasad venkata ramasatya Nandagiri

unread,
May 24, 2018, 3:09:28 PM5/24/18
to Jenkins Users
was it resolved? if so, please let me know the solution

Andrew Gray

unread,
Mar 5, 2019, 11:22:27 PM3/5/19
to Jenkins Users
Did you end up working out how to post a file to a url in Jenkins pipeline?

Anonymous

unread,
Mar 28, 2019, 11:10:12 AM3/28/19
to Jenkins Users
Does someone solve this issue ? I feel like requestBody isn't working at all. However if I'm making a "basic" POST request with query like "http://localhost:5000/api?id=1" it does work..

deepak t.s

unread,
Aug 2, 2019, 4:10:51 AM8/2/19
to Jenkins Users
------------------------
This worked for Me : 
def response =  httpRequest(acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_ZIP',
customHeaders : [[name: "authorization" , value : "${authToken}"],[name: 'x-username' , value: 'admin']],
httpMode: 'POST', ignoreSslErrors: true, multipartName: 'AppDefenseBundle.zip', timeout: 900,
                         responseHandle: 'NONE', uploadFile: "${bundleUploadPath}", url: "${url}") 
Reply all
Reply to author
Forward
0 new messages