Creating REST plugin procedures

3 minute readExtensibilityDeveloper productivity
On this page

Plugin procedures can be used in procedure steps, process steps, and pipeline tasks, allowing you to orchestrate third-party tools at the appropriate time in your component, application process, or pipeline.

Depending on your plugin configuration and how you run procedures, the Input parameters  Configuration name field may behave differently in the CloudBees CD/RO UI. For more information, refer to Differences in plugin UI behavior.

runRest

Use this procedure to allow the input of any HTTP request that is defined in the provided fields of the parameters. The plugin analyzes the parameters and attempts to create and send the HTTP request. After the request is sent, the plugin analyzes the response and returns the result, as either a success or failure.

Input parameters

Table 1. runRest input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Ignore auth

When selected, the credential specified in the configuration for this request is ignored.

Request type

Required. Includes the following options: GET, POST, PUT, PATCH, HEAD, or DELETE.

Request timeout

REST client request timeout in seconds. If not set or defined in Default request timeout, 180s is used.

Path URL

Relative URL Path. For example, service.

Query options

Newline-separated request query options in format option_name=option_value.

Content type

Content type required for the request. Used to check the connection. Examples:

  • text/plain

  • application/json; charset=utf-8

Accepted MIME types

Content types, expressed as MIME types, the client can understand.

Cookie value

Value sent as a cookie. Used for checking connection. Example:

  • foo1=bar1;foo2=bar2

Headers

Provide the headers required for the request. Used to check the connection. For more than one header, write each header on a new line. Key-value pairs may be written separated by a whitespace, colon, or equals. Example (note that each key-value pair must appear on a new line):

simple_header simple_value header3:third myHeader=myValue

Form content

Provide the content required for the request. For example: {"key" : "value", "tag" : "ttt", "level" : 1}

Source file

Path to a file that provides the content required for the request. Used instead of Form Content field. For example: /path/to/text/content.txt

Download to file

Enables content to be downloaded to a file.

Target file

Name of the target file for downloading.

Post-processing script shell

The shell used to execute the provided script. Entry may be an absolute file path (/usr/bin/python) or a shell name if it is contained in the $PATH environment variable, such as cb-perl.

Post-processing script content

Script content used for response handling executed by the shell referenced in Post script shell.

Post-processing script output file

File path, relative or absolute, to store the result of the post process script. If specified, STDOUT of the post script will be saved into this file. If the file name is relative, the file is saved into the job workspace.

Result property path

The property with the response body, such as /myJob/resultBody, or path to the target file if Download to file is selected.

Response regular expression for polling

Regular expression to evaluate for the response content. If the parameter is provided, the request is performed repeated times until it matches the response content or the timeout expires. If the parameter is not provided, it is not evaluated, and the request is performed once. Examples:

  • 1\d{10}

  • \d{5}(-\d{4})?

Output parameters

Table 2. runRest output parameters
Parameter Description

headers

Headers type from response

cookie

Cookie from response

body

The response body or path to target file.