Skip to content

Hook Definition

sigoden edited this page Jul 11, 2017 · 1 revision

Hook definition

Hooks are defined as JSON objects. Please note that in order to be considered valid, a hook object must contain the id and execute-command properties. All other properties are considered optional.

Properties (keys)

  • id - specifies the ID of your hook. This value is used to create the HTTP endpoint (http://yourserver:port/hooks/your-hook-id)
  • execute-command - specifies the command that should be executed when the hook is triggered
  • command-working-directory - specifies the working directory that will be used for the script when it's executed
  • response-message - specifies the string that will be returned to the hook initiator
  • response-headers - specifies the list of headers in format {"name": "X-Example-Header", "value": "it works"} that will be returned in HTTP response for the hook
  • include-command-output-in-response - boolean whether webhook should wait for the command to finish and return the raw output as a response to the hook initiator. If the command fails to execute or encounters any errors while executing the response will result in 500 Internal Server Error HTTP status code, otherwise the 200 OK status code will be returned.
  • parse-parameters-as-json - specifies the list of arguments that contain JSON strings. These parameters will be decoded by webhook and you can access them like regular objects in rules and pass-arguments-to-command.
  • pass-arguments-to-command - specifies the list of arguments that will be passed to the command. Check Referencing request values page to see how to reference the values from the request. If you want to pass a static string value to your command you can specify it as { "source": "string", "name": "argumentvalue" }
  • pass-environment-to-command - specifies the list of arguments that will be passed to the command as environment variables. If you do not specify the "envname" field in the referenced value, the hook will be in format "HOOK_argumentname", otherwise "envname" field will be used as it's name. Check Referencing request values page to see how to reference the values from the request. If you want to pass a static string value to your command you can specify it as { "source": "string", "envname": "SOMETHING", "name": "argumentvalue" }
  • trigger-rule - specifies the rule that will be evaluated in order to determine should the hook be triggered. Check Hook rules page to see the list of valid rules and their usage
  • trigger-rule-mismatch-http-response-code - specifies the HTTP status code to be returned when the trigger rule is not satisfied

Examples

Check out Hook examples page for more complex examples of hooks.