HTTP/S Connector

What is the HTTP/S Connector?

A connector in PIPEFORCE is one or more commands allowing you to connect to external systems and exchange data with them.

The HTTP/S Connector allows to connect to such external systems using the HTTP/S protocol. For example if you would like to make RESTful calls.

Typically such endpoints are secured with username and password or a token. You should never place such sensitive data into your source code. Instead, create a new and refer to it in your pipeline.

Here is an example to access the GitHub API using the command http.get and a custom secret, created before:

pipeline: - http.get: url: "https://api.github.com/owner/repo/actions/artifacts" secret: "github-secret"

This will return a JSON document like this example, which can be used in the pipeline for further processing:

{ "total_count": 1, "artifacts": [ { "id": 11, "node_id": "MDg6QXJ0bbZhY3QxMQ==", "name": "Rails", "size_in_bytes": 556, "url": "https://api.github.com/repos/owner/repo/actions/artifacts/11", "archive_download_url": "https://api.github.com/repos/owner/repo/actions/artifacts/11/zip", "expired": false, "created_at": "2022-01-10T14:59:22Z", "expires_at": "2022-03-21T14:59:22Z", "updated_at": "2022-02-21T14:59:22Z", "workflow_run": { "id": 2332928, "repository_id": 1296569, "head_repository_id": 1296219, "head_branch": "main", "head_sha": "328faa0536e6fef19903d9d91dc96a9931694ce3" } } ] }

Also see these connector commands:

HTTP Body

In order to set the body for an HTTP request, you can use the body parameter:

pipeline: - http.post: url: http://hostname/path body: "This is the HTTP body of the POST request"

You can also “link” to the body of the pipeline and use this for the POST body:

If no body parameter is set. Then the value from the input parameter will be used as body. If this is also null, not body will be set at all.

HTTP Headers

You can set HTTP headers using the headers parameter. It expects the headers as name-value pairs.

Example: