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.
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.
- 
Make sure you have API access by following the instructions in API 
- 
Take note of the ID ( <pipeline_id>) of a pipeline that runs thedeployoperation 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/outgoingto create an outgoing webhook for theaction.startedevent. 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 <your_api_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/outgoingto create an outgoing webhook for theaction.failedevent. 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 <your_api_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.contextneeds 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/outgoingto create an outgoing webhook for theaction.completedevent. 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 <your_api_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 <your_api_token>' \
 --header 'Content-Type: application/json'
- 
In the previous command response, the recently created hooks will be included in the list