I have implemented the following function within a Jenkins Shared Library.
/* This function is designed to delete uploads that are stored on the server. */
def delete_upload(server_url,each_upload_id,authentication){
def delete_upload_url = server_url + "/api/v1/uploads/" + each_upload_id
def response = httpRequest consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
customHeaders: [[maskValue: false, name: 'id ', value: each_upload_id],
[maskValue: false, name: 'Authorization', value: authentication]],
httpMode: 'DELETE', ignoreSslErrors: true, responseHandle: 'NONE', url: delete_upload_url,
validResponseCodes: '100:599'
if(response.status == 202){
def result = readJSON text: """${response.content}"""
return result['message'].toString()
}
else {
throw new Exception("Incorrect upload id! Please provide the correct upload id.")
}
}
====================================================================================================
After making use of the above function,
Response Code: HTTP/1.1 202 Accepted Response: {"code":202,"message":"Delete Job for file with id 2","type":"INFO"} Success: Status code 202 indicates acceptance within the range of 100:599
====================================================================================================
Purpose: The intention behind using the aforementioned JSL function is to remove uploads from a web server utilizing their upload ids.
Requirement:
I am looking to delete multiple uploads by supplying various upload ids (such as each_upload_id being 1, 2, 3 etc) using the provided JSL delete function.
The goal is to iterate through the upload ids and delete the corresponding uploads on the web server.
If you have any suggestions, please share them.