An IncomingWebhook
resource can trigger one or more jobs in your pipeline whenever the associated URL is called using the HTTP POST method.
When an IncomingWebhook
resource is created with an Incoming Webhook Integration, it can be specified as an input to any step in that step's inputResources
section. By default, any incoming payload from the webhook will trigger execution of the step, but this can be changed by setting trigger
to false
.
Any JSON payload passed in by the received POST call is stored in the payload
property of the resource.The step can access the JSON payload through the res_<resource_name>_payload
environment variable. The value of the environment variable can be written to a file, and individual elements can be read from that file using the read_json utility function.
When using Webhook as an output resource, you can construct the outgoing payload through the write_output utility function to add key/value pairs.
You can use an IncomingWebhook
resource to trigger execution of another pipeline. When specified as an output resource of a step in one pipeline and an input resource of a step in a different pipeline, setting a payload for the IncomingWebhook
in the first step will trigger execution of the other step. In this way, completion of a step in one pipeline can trigger execution of a different pipeline.
Incoming Webhooks and Multi Branch Pipelines
When working with Multi Branch Pipelines, to trigger an IncomingWebhook
resource for a specific Pipelines Source branch, you need to add the branch query parameter to your Incoming Webhook URL as follows:
http://host:port/pipelines/api/v1/projectIntegrations/1/hook?branch=>
Example
http://host:port/pipelines/api/v1/projectIntegrations/1/hook?branch=foo
YAML Schema
resources: - name: <string> type: IncomingWebhook configuration: webhookName: <string>
Tags
name
An alphanumeric string (underscores are permitted) that identifies the resource.
type
Must be IncomingWebhook
for this resource type.
configuration
Specifies all configuration selections for the resource.
Tag | Description | Required/Optional |
---|---|---|
| The name of an Incoming Webhook Integration | Required |
Environment Variables
WheneverIncomingWebhook
is used in a step, a set of environment variables is automatically made available that you can use in your step.
Environment Variable | Description |
---|---|
res_<resource_name>_name | Name of the resource |
res_<resource_name>_payload | Webhook payload that was received in the incoming POST or created by the step for output |
Example
This example requires an Incoming Webhook Integration.
The Pipelines DSL for this example is available in this repository in the JFrog GitHub account.
resources: - name: MyIncomingWebhookResource type: IncomingWebhook configuration: webhookName: MyIncomingWebhookIntegration pipelines: - name: ExamplePipeline steps: - name: ExampleStep type: Bash configuration: inputResources: - name: MyIncomingWebhookResource execution: onExecute: - echo "$res_MyIncomingWebhookResource_payload" | jq '.' > payload.json - read_json payload.json "LESSER_SECRET_FORMULA"