Webhook External Command #6872

Open
opened 2025-11-02 07:09:36 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @jolheiser on GitHub (Feb 15, 2021).

Related to #1089

Preface, a plugin system would potentially be nicer, but also more complicated. I've opted to open this proposal to see if there is interest.


I'm in the beginning stages of working out how an external command could work.
In my opinion this could cover a vast majority of cases, as the command could also do any data processing and HTTP calls as necessary.

name: custom-py
# Not sure if this should be a local path or URL. If local, Gitea needs a way to serve it e.g. in the custom/img folder
image: /path/to/image.png 
command: [python, /usr/local/bin/custom.py]
form:
  - title: Channel ID
    help: The channel to post to
    required: true

Things inside form would be used by Gitea to present the webhook form. Probably by transforming the title e.g. channel_id from above.

I'm thinking the current gitea JSON payload could be sent to the command via stdin.
I'm not 100% sure how to pass along form inputs, perhaps an enclosing JSON object ?

{
  "form": {...},
  "payload": {...}
}

Then the command can unmarshal the JSON and do whatever it needs to.

Originally created by @jolheiser on GitHub (Feb 15, 2021). Related to #1089 Preface, a plugin system would potentially be nicer, but also more complicated. I've opted to open this proposal to see if there is interest. ----- I'm in the beginning stages of working out how an external command could work. In my opinion this could cover a vast majority of cases, as the command could also do any data processing and HTTP calls as necessary. ```yaml name: custom-py # Not sure if this should be a local path or URL. If local, Gitea needs a way to serve it e.g. in the custom/img folder image: /path/to/image.png command: [python, /usr/local/bin/custom.py] form: - title: Channel ID help: The channel to post to required: true ``` Things inside `form` would be used by Gitea to present the webhook form. Probably by transforming the `title` e.g. `channel_id` from above. I'm thinking the current `gitea` [JSON payload](https://docs.gitea.io/en-us/webhooks/#event-information) could be sent to the `command` via `stdin`. I'm not 100% sure how to pass along form inputs, perhaps an enclosing JSON object ? ```json { "form": {...}, "payload": {...} } ``` Then the `command` can unmarshal the JSON and do whatever it needs to.
GiteaMirror added the type/proposal label 2025-11-02 07:09:36 -06:00
Author
Owner

@zeripath commented on GitHub (Feb 15, 2021):

This seems like a potential solution - of course windows users will cause no limit of trouble.

If we do this - do not use exec.Command but rather extend the modules/process/manager.go to have a nicer Exec that will take a readers and write to writers. Then the process becomes cancellable from the admin page etc.

@zeripath commented on GitHub (Feb 15, 2021): This seems like a potential solution - of course windows users will cause no limit of trouble. If we do this - do not use exec.Command but rather extend the modules/process/manager.go to have a nicer Exec that will take a readers and write to writers. Then the process becomes cancellable from the admin page etc.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6872