HTTP Request Plugin

httpRequest: Perform an HTTP Request and return a response object

Performs an HTTP request, and returns a response object.

Usage example:

        def response = httpRequest 'http://localhost:8080/jenkins/api/json?pretty=true'
        println("Status: "+response.status)
        println("Content: "+response.content)
        

If Jenkins restarts after the HTTP request is made, but before the HTTP response is received, the HTTP request fails.

The methods of the response object are:

  • String getContent(): The HTTP Response entity. This means the text of the response without the headers. If the response does not contain an entity, getContent() returns null.
  • int getStatus(): The HTTP status code.

url

Type: String

acceptType (optional)

Values:

  • NOT_SET

  • TEXT_HTML

  • TEXT_PLAIN

  • APPLICATION_FORM

  • APPLICATION_JSON

  • APPLICATION_JSON_UTF8

  • APPLICATION_TAR

  • APPLICATION_ZIP

  • APPLICATION_OCTETSTREAM

authentication (optional)

Type: String

consoleLogResponseBody (optional)

Type: boolean

contentType (optional)

Values:

  • NOT_SET

  • TEXT_HTML

  • TEXT_PLAIN

  • APPLICATION_FORM

  • APPLICATION_JSON

  • APPLICATION_JSON_UTF8

  • APPLICATION_TAR

  • APPLICATION_ZIP

  • APPLICATION_OCTETSTREAM

customHeaders (optional)

Array/List

Nested Object

name

Type: String

value

Type: String

maskValue

Type: boolean

httpMode (optional)

Values:

  • GET

  • HEAD

  • POST

  • PUT

  • DELETE

  • OPTIONS

  • PATCH

httpProxy (optional)

Type: String

ignoreSslErrors (optional)

Type: boolean

outputFile (optional)

Type: String

quiet (optional)

Type: boolean

requestBody (optional)

Type: String

responseHandle (optional)

Values:

  • NONE

  • LEAVE_OPEN

  • STRING

timeout (optional)

Type: int

validResponseCodes (optional)

Type: String

validResponseContent (optional)

Type: String