Issue with HTTPRequest Jenkins Plugin in JenkinsFile for Deleting Nexus Components via API

Hi everyone,

I’m trying to delete components in Nexus using the httpRequest plugin in a Jenkins pipeline. The deletion works — the component gets deleted from Nexus — but I never receive the expected 204 No Content response. Instead, I encounter an error: groovy.json.internal.LazyMap.

Below is my code snippet:
def deleteResponse = httpRequest(
url: “${env.NEXUS_URL}/service/rest/v1/components/${componentId}”,
httpMode: ‘DELETE’,
authentication: ‘nexus_credentials’,
customHeaders: [
[name: ‘accept’, value: ‘application/json’],
[name: ‘Content-Type’, value: ‘application/json’]
],
validResponseCodes: ‘100:599’,
responseHandle: ‘NONE’
)

echo “HTTP Response Status: ${deleteResponse.status}”

The pipeline never reaches the echo line after the httpRequest call. To test, I wrapped the code in a try-catch block, which allowed it to proceed, but that’s not how I’d prefer to handle this.

Details:

  • Nexus OSS Version: 3.68.1-02
  • Repository Format: maven2

Question:

Has anyone experienced a similar issue? If so:

  1. How did you handle the httpRequest response to avoid the error?
  2. Is there a configuration or workaround that ensures proper handling of the 204 response (or no response body)?

Thanks in advance for your help!

I suspect you may have a syntax error which either prevents the outbound call, or breaks the internal handling of the plugin you’re using.

Hi @mpiggott , thank you for your answer. I tried so many different combinations already and all leads the same, the component is deleted but it gives error in the request call =(. for now it is in a try catch until I can find a solution.

If you haven’t, try printing the stacktrace of the error - the Jenkins source code is generally public so you may be able to track down the cause.