Skip to content

Add an "export" operation to store environment variables

Peter Hutterer requested to merge whot/hookiedookie:wip/export into main

This enables users of hookiedookie to extract most of the information they need from the payload and pass it through to the workload as environment variables - thus removing the need of the callers to handle the payload format themselves.

Example would be to extract the issue id from a gitlab webhook roughly like this:

   rules:
     and:
       - matches:
           key: "object_kind"
           value: "issue"
       - follow:
           key: "object_attributes"
           op:
             export:
               key: "id"
               name: "GITLAB_ISSUE_ID"
   run:
     - "bash"
     - "-c"
     - "do_something $GITLAB_ISSUE_ID"

The export: operation can succeed or fail - the latter allowing it to be used in an or/any operation without affecting the result of that operation.

These exports are treated as "side effects" in the code, with environment variables being the only currently supported side effect.

The parsing of string-based values needs to be special-cased to not end up with strings like ""foo", otherwise the values are serialized back to JSON mostly as expected.

Merge request reports

Loading