Reputation: 1092
I have a requirement to upload zip file to appDynamics, i need to use the httpsrequest plugin for that from my jenkins pipeline
upload request for appdynamics:
curl -v -H Content-Type:application/octet-stream --upload-file UISampleApp.app.dSYM.zip --user Example account:Example-License-Key-4e8ec2ae6cfe https://api.eum-appdynamics.com/v2/account/Example+account/ios-dsym
we are using a shell to execute the above request now but I am trying to find out how to sent multiple zip files using httpsRequest plugin
Upvotes: 1
Views: 7604
Reputation: 14815
To upload a file using httpRequest, 3 elements are required:
Example:
def response = httpRequest(
url: "${url}",
authentication: CREDENTIALS_IF_NEEDED,
httpMode: 'POST',
contentType: 'APPLICATION_OCTETSTREAM',
uploadFile: "${path}",
multipartName: "${fileName}",
wrapAsMultipart: false
)
Example of URL:
"http://www.mygitea.com:3000/api/v1/repos/User/Project/releases/assets?name=${fileName}"
Example of path:
"${WORKSPACE}\\image.png" #Windows only
"${WORKSPACE}/image.png" #Linux/Unix
Example of fileName:
"image.png"
Upvotes: 0
Reputation: 317
Following Code 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: '<fileName>', timeout: 900,
responseHandle: 'NONE', uploadFile: "<filePath>",
url: "${url}")
Upvotes: 3
Reputation: 139
I think upload will use Content-Type: multipart/form-data
. But httpRequest plugin is not supporting this type. However it supports APPLICATION_OCTETSTREAM(ContentType.APPLICATION_OCTET_STREAM)
Could you post output from your curl?
Upvotes: 0
Reputation: 53
Looks like httprequest plugin does not support uploading zip file. This is my observation.
Upvotes: 0