"actions" are Python modules that, if available in the PYTHONPATH
,
can be run by updating the module
attribute of the YAML config file.
Let's create a new_action
!
-
First, add a new Python file (eg.
my_team_action.py
) in thejbi/actions/
directory. -
Add the Python function
init
to the module, for example:from jbi import ActionResult, Operation from jbi.models import ActionContext JIRA_REQUIRED_PERMISSIONS = {"CREATE_ISSUES"} def init(jira_project_key, optional_param=42): def execute(context: ActionContext) -> ActionResult: print(f"{optional_param}, going to {jira_project_key}!") return True, {"result": 42} return execute
- In the above example the
jira_project_key
parameter is required optional_param
, which has a default value, is not required to run this actioninit()
returns a__call__
able object that the system calls with theActionContext
object- The returned
ActionResult
features a boolean to indicate whether something was performed or not, along with aDict
(used as a response to the WebHook endpoint).
- In the above example the
-
Use the
context.bug
,context.event
,context.jira
information to perform the desired processing! -
List the required Jira permissions to be set on projects that will use this action in the
JIRA_REQUIRED_PERMISSIONS
constant. The list of built-in permissions is available on Atlassian API docs. -
Use the available service calls from
jbi/services
(or make new ones) -
Update the
README.md
to document your action -
Now the action
jbi.actions.my_team_actions
can be used in the YAML configuration, under themodule
key.