The following plugin provides functionality available through
Pipeline-compatible steps. Read more about how to integrate steps into your
Pipeline in the
section of the
For a list of other such plugins, see the
Pipeline Steps Reference
HTTP Request Plugin
httpRequest: Perform an HTTP Request and return a response object
Performs an HTTP request, and returns a response object.
def response = httpRequest 'http://localhost:8080/jenkins/api/json?pretty=true'
If Jenkins restarts after the HTTP request is made, but before the HTTP response is received, the HTTP request fails.
validResponseCodes is a comma-separated string of single values or from:to ranges. For example '200' to accept only 200 or '201,301:303' to accept 201 as well as the range from 301 to 303.
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.
Specify an URL to be requested.
Accept: foo HTTP request header where
foo is the HTTP content type to accept.
Authentication that will be used before this request. Authentications are created in global configuration under a key name that is selected here.
This allows to turn off writing the response body to the log.
Content-Type: foo HTTP request header where
foo is the HTTP content type the request is using.
Array / List of Nested Object
The HTTP mode of the request such as 'GET' or 'POST'.
Use a proxy to process the HTTP request. Example: http://mycorpproxy:80
If set to true, a request with HTTPS will trust in the certificate even when it is invalid or expired.
Multipart entity name used in the Content-Disposition header in conjunction with the upload file path.
Name of the file in which to write response data.
This allows to turn off all logging output.
The raw body of the request.
Parameters will be resolved.
How response should be handled.
STRING(default) will transform the response in string.
NONE will not read the response content and will close the response after the job execution.
LEAVE_OPEN will not read the response content but leaves an open input stream to be read outside the job execution. Using LEAVE_OPEN it is your responsibility to close it after use. 'response.close();'
Specify a timeout value in seconds (default is 0 which implies no timeout).
Path to the upload file, relative to build workspace or absolute path.
Can be used to upload a file as multipart/form-data POST
request. The according content type should be set above, defaults to application/octet-stream
Configure response code to mark an execution as success.
You can configure simple code such as "200" or multiple codes separeted by comma(',') e.g. "200,404,500"
Interval of codes should be in format From:To e.g. "100:399".
The default (as if empty) is to fail to 4xx and 5xx. That means success from 100 to 399 "100:399".
To ignore any response code use "100:599".
If set response must contain this string to mark an execution as success.
If set to false an upload file will be set directly as body of the request and will not be wrapped as multipart/form-data.
Was this page helpful?
Please submit your feedback about this page through this
Alternatively, if you don't wish to complete the quick form, you can simply
indicate if you found this page helpful?
See existing feedback here.