Integrate Application deployments with your Continuous Integration (CI) workflows
Learn how to create outgoing webhooks to integrate the application deployment with your existing CI workflow.
NOTE: Webhooks, for now, are an API only feature; so this post will guide you through the usage of our API to help you create an outgoing webhook.
NOTE: The examples below use cURL
, which is a command line utility to be used from a terminal window. If you're not familiar with running commands on a terminal or you simply don't want to use a terminal you could, alternatively, copy the examples and import the cURL
command line into your favorite API client platform. Here are links with instructions on how to achieve that on some of the most popular API client platforms:
-
Take note of the ID (
<pipeline_id>
) of a pipeline that runs thedeploy
operation for the application which you want to watch the action statuses- Follow the Deploy Application using an Incoming Hook guide for detailed instructions
-
Take note of the
Target URL
(<target_url>
),Request Headers
(<request_headers>
) andRequest Body
(<request_body>
) fields according to the source provider where the application' source code is hosted, by following the source provider's instructions on the links bellow: -
On your local machine, in a terminal window, submit a request to Devopness API endpoint
POST /pipelines/:id/hooks/outgoing
to create an outgoing webhook for theaction.started
event. In the example below, replace<pipeline_id>
,<target_url>
,<request_headers>
and<request_body>
with the actual values of each parameter before submitting the request.- For further instructions, follow the guide Create an Outgoing Webhook
curl --request POST \ --url https://api.devopness.com/pipelines/<pipeline_id>/hooks/outgoing \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "CI(build)", "action_type": "deploy", "target_url": "https://<target_url>/{{ action.triggered_from.hook_parsed_variables.commit_hash }}", "settings": { "request_headers": [ { "name": "Authorization", "value": "Bearer {{ application.source_provider.access_token }}" } // NOTE: add Request Headers (`<request_headers>`) here ], "request_body": { // NOTE: review the fields bellow according to Request Body (`<request_body>`) from the source provider instructions "state": <source_provider_pipeline_status>, "target_url": "https://app.devopness.com/actions/{{ action.id }}", "url": "https://app.devopness.com/actions/{{ action.id }}", "description": "Application building started", "context": "ci\/devopness(build)", "key": "ci\/devopness(build)" } }, "trigger_when": { "events": [ "action.started" ] } }'
-
On your local machine, in a terminal window, submit a request to Devopness API endpoint
POST /pipelines/:id/hooks/outgoing
to create an outgoing webhook for theaction.failed
event. In the example below, replace<pipeline_id>
,<target_url>
,<request_headers>
and<request_body>
with the actual values of each parameter before submitting the request.curl --request POST \ --url https://api.devopness.com/pipelines/<pipeline_id>/hooks/outgoing \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "CI(build)", "action_type": "deploy", "target_url": "https://<target_url>/{{ action.triggered_from.hook_parsed_variables.commit_hash }}", "settings": { "request_headers": [ { "name": "Authorization", "value": "Bearer {{ application.source_provider.access_token }}" } // NOTE: add Request Headers (`<request_headers>`) here ], "request_body": { // NOTE: review the fields bellow according to Request Body (`<request_body>`) from the source provider instructions "state": <source_provider_pipeline_status>, "target_url": "https://app.devopness.com/actions/{{ action.id }}", "url": "https://app.devopness.com/actions/{{ action.id }}", "description": "Application building failed", "context": "ci\/devopness(build)", "key": "ci\/devopness(build)" } }, "trigger_when": { "events": [ "action.failed" ] } }'
- NOTE: the field
request_body.context
needs to be the same for all the action status; this way the same commit status will be updated, instead of creating a new entry for every state.
- NOTE: the field
-
On your local machine, in a terminal window, submit a request to Devopness API endpoint
POST /pipelines/:id/hooks/outgoing
to create an outgoing webhook for theaction.completed
event. In the example below, replace<pipeline_id>
,<target_url>
,<request_headers>
and<request_body>
with the actual values of each parameter before submitting the request.curl --request POST \ --url https://api.devopness.com/pipelines/<pipeline_id>/hooks/outgoing \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "CI(build)", "action_type": "deploy", "target_url": "https://<target_url>/{{ action.triggered_from.hook_parsed_variables.commit_hash }}", "settings": { "request_headers": [ { "name": "Authorization", "value": "Bearer {{ application.source_provider.access_token }}" } // NOTE: add Request Headers (`<request_headers>`) here ], "request_body": { // NOTE: review the fields below according to Request Body (`<request_body>`) from the source provider instructions "state": <source_provider_pipeline_status>, "target_url": "https://app.devopness.com/actions/{{ action.id }}", "url": "https://app.devopness.com/actions/{{ action.id }}", "description": "Application building success", "context": "ci\/devopness(build)", "key": "ci\/devopness(build)" } }, "trigger_when": { "events": [ "action.completed" ] } }'
-
On your local machine, in a terminal window, run command to list all the pipeline webhooks, replacing
<pipeline_id>
.curl --request GET \ --url https://api.devopness.com/pipelines/<pipeline_id>/hooks \ --header 'Accept: application/json' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json'
-
In the previous command response, the recently created hooks will be included in the list