webhook

adnanhMIT活跃维护

轻量级入站 webhook 服务器,收到 HTTP 请求就触发执行预设的 shell 命令,适合做自动化部署和 CI 钩子。

webhook is a lightweight incoming webhook server to run shell commands

2.8.3发布于 2026-02-12 22:46 UTC12,210star +2 / 7 天882fork同步于 2026-11-10 11:28 UTC

怎么上手

由 README 提炼,执行前请确认
go build github.com/adnanh/webhook
/path/to/webhook -hooks hooks.json -verbose
硬件要求按 README 说明

README 未说明硬件要求;为 Go 编写的轻量服务,可编译为预构建二进制运行,未提及 GPU 或显存需求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

轻量级 Go 编写的入站 webhook 服务器,把 HTTP 请求映射成本地 shell 命令执行

轻量级入站 webhook 服务器,收到 HTTP 请求就触发执行预设的 shell 命令,适合做自动化部署和 CI 钩子。

核心能力

  • 用 JSON 或 YAML 定义 hook 与执行命令
  • 把请求头、payload、查询参数传给命令或环境变量
  • 用 trigger-rule 规则校验后才触发命令
  • 支持 -secure 加证书私钥启用 HTTPS
  • 支持 Unix socket 与 systemd socket 激活

容易踩的坑

默认监听 9000 端口,需确认端口未被占用或另行指定;不加 trigger-rule 时任何知道端点的人都能触发命令执行;从源码构建需 Go 1.21 或更新版本

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本2.8.3
  1. 2.8.3webhook 2.8.3最新正式版2026-02-12 · 2026-02-12 22:46 UTC

    Enhancements

    • Added Printing the Raw Webhook Payload to Standard Output example (#746)
    • Add cat and credential template functions (#712, #720)

    Internal & Documentation updates

    • Documented cat and credential template functions (#739)
    • Fixed Gitea incoming webhook example and added a YAML version (#737)
    • Added ACR webhook to Hook-Examples.md (#731)
    • Removed reference to Hookecho (#711)
    • Use CGO_ENABLED=0 for release builds (#705)

    Binaries

    I've attached binaries that I've managed to cross-compile without problems.

    MD5 checksums

    9c353e1b53bca75b09da112b4c834d3b  webhook-darwin-amd64.tar.gz
    1d1610ba016ba7148722daa65cd5d985  webhook-freebsd-386.tar.gz
    d61a4cf967645a5a544f0a602d448014  webhook-freebsd-amd64.tar.gz
    8cbee4fe6c977b4f0c04298ea46a0cf0  webhook-freebsd-arm64.tar.gz
    daea6109886a2cea8047bc5da24023b9  webhook-freebsd-arm.tar.gz
    b024b5cd05f8670dac6b03f7b2b188e4  webhook-linux-386.tar.gz
    1489d4a9707a976615f5997d75e4ed23  webhook-linux-amd64.tar.gz
    42111cd3dadfd0107f64c553729867c8  webhook-linux-arm64.tar.gz
    3ef9d365aef90e68cfcc5ba8fc9ad80e  webhook-linux-arm.tar.gz
    b59e8875053f14f7ddc073994e5056b3  webhook-openbsd-386.tar.gz
    06eab0b3c3066abda54b418021ad6eec  webhook-openbsd-amd64.tar.gz
    3bb4a8980eb267f7a73c19c8ff86c12a  webhook-openbsd-arm64.tar.gz
    1818b98ab8eb91ca511de2ab64a56d1e  webhook-openbsd-arm.tar.gz
    
  2. 2.8.2webhook 2.8.22024-10-25 · 2024-10-25 21:26 UTC
    查看更新说明

    Enhancements

    • Add support for setuid/setgid in Linux (#646)
    • Add option to bind to a Unix socket instead of a TCP port (#703)
    • Add support for systemd socket activation (#704)

    Internal & Documentation updates

    • Reformat some code blocks (#637)
    • Fix some typos (#652, #685)
    • Add Zola Guide (#653)
    • Update dependencies (#681)

    Binaries

    I've attached binaries that I've managed to cross-compile without problems.

    MD5 checksums

    MD5 (webhook-darwin-amd64.tar.gz) = 11dd7272fc9fc1ebe0d8feabe9a35645
    MD5 (webhook-darwin-arm64.tar.gz) = c137bc3564a191c21467ee26a5d7b5d3
    MD5 (webhook-freebsd-386.tar.gz) = 9b26dc1fb0d60da62e2f0ccfa6eba7f3
    MD5 (webhook-freebsd-amd64.tar.gz) = 1411f438b37fc750519bf72a456075c8
    MD5 (webhook-freebsd-arm.tar.gz) = 5a795c8b58a314f5a34cdbb35992d491
    MD5 (webhook-freebsd-arm64.tar.gz) = 055939ced041b6b8d73a0d70960a6488
    MD5 (webhook-linux-386.tar.gz) = 4e1c3e43efb27d64841cae273b54bad8
    MD5 (webhook-linux-amd64.tar.gz) = 84f2d581d549236512d3c214e7d97bf7
    MD5 (webhook-linux-arm.tar.gz) = 1971e629731faacb07e46a7efb10fedc
    MD5 (webhook-linux-arm64.tar.gz) = 59b70a87d4f473e3ff346065655ab5a7
    MD5 (webhook-openbsd-386.tar.gz) = af32cc1893251fc31a65ac708d79fb25
    MD5 (webhook-openbsd-amd64.tar.gz) = 8da3a9ca26957e0e862f3a41aa9450d3
    MD5 (webhook-openbsd-arm.tar.gz) = 66b179cbbbe74d9ad047d1b9e172b99a
    MD5 (webhook-openbsd-arm64.tar.gz) = f07069333f5dacf97cbfc0782ffef115
    MD5 (webhook-windows-386.tar.gz) = c036a0f9af5298fc205eecb14b7818d8
    MD5 (webhook-windows-amd64.tar.gz) = aab4db8a21269d54b919a7ab540f4c17
    MD5 (webhook-windows-arm.tar.gz) = e0e0a38a454021712b23e02125a7ed9d
    MD5 (webhook-windows-arm64.tar.gz) = 310a1f61a3727ab0e27bb26e0046d4c2
    
  3. 2.8.1webhook 2.8.12023-05-22 · 2023-05-22 19:24 UTC
    查看更新说明

    Bugfixes

    Send CLI headers on default HTTP handler (#554)

    Binaries

    I've attached binaries that I've managed to cross-compile without problems.

    MD5 checksums

    9eeb4e698b7a7e142e3cd63371fd59e2  webhook-darwin-amd64.tar.gz
    24984c7bda05c31c4a72d5503e6af0a4  webhook-darwin-arm64.tar.gz
    10ed4807876c66bbd39e080158baef8a  webhook-freebsd-386.tar.gz
    5dce952364f379a4fe153a26b045d94a  webhook-freebsd-amd64.tar.gz
    75f14e4337b6dfcb1841de05abebaa79  webhook-freebsd-arm64.tar.gz
    1fbb879c8d5967e27b65d49131c2590b  webhook-freebsd-arm.tar.gz
    e5e526d6b393e3101db76c655f537883  webhook-linux-386.tar.gz
    861381a4c3b8b485b56665d9196978d8  webhook-linux-amd64.tar.gz
    f08523e12dcb5189306badf224003a79  webhook-linux-arm64.tar.gz
    eaad58b6b1fddc3c412161074da9a3d6  webhook-linux-arm.tar.gz
    af63d022efce78685118c9100d6dde29  webhook-openbsd-386.tar.gz
    50d7f02869421c1e039c65a64e8de3ee  webhook-openbsd-amd64.tar.gz
    c388aefac25caa754c8c82eec4595876  webhook-openbsd-arm64.tar.gz
    71e25f1df260f91d79b296e8a027c467  webhook-openbsd-arm.tar.gz
    0e32a28857e7c4bde1d286ebea14585a  webhook-windows-386.tar.gz
    0abac709bf6addf2c0b80bb7c979d092  webhook-windows-amd64.tar.gz
    8cb5996e47eeb5ddbd38dbe2f604f6ec  webhook-windows-arm.tar.gz
    
  4. 2.8.0webhook 2.8.02020-12-06 · 2020-12-06 08:02 UTC
    查看更新说明

    Enhancements

    • Add option to send raw request body to command (#486)
    • Add soft signature failure support (#485)
    • Add support for slashes in hook IDs (#484)
    • Add request source (#479)
    • Transition payload hash option names to hmac (#461)
    • Return JSON format when referenced value is not a simple type enhancement (#448)
    • Update ExtractParameterAsString to return JSON on complex types (#449)
    • Add support for top-level JSON array in payload (#446)

    Bugfixes

    • Fix OrRule logic on parameter lookup failures (#472)
    • Log stdlib error on failed exec.LookPath (#460)
    • Bugfix/require go14 (#445)
    • Tighten file permissions on pidfile creation (#431)
    • Fix request dumper (#426)

    Internal & Documentation updates

    • Add string parameter example to docs (#489)
    • Move some request parsing into hook package (#477)
    • Document YAML support (#463)
    • Add Request object to hook package to simplify API proposal (#462)
    • Add a table of contents to some of the docs (#447)

    Binaries

    I've attached binaries that I've managed to cross-compile without problems.

    MD5 checksums

    d034baac6741fe0b0914cc933231475f  webhook-windows-386.tar.gz
    0b5895ce6b721c151e5a7ba499c3092a  webhook-windows-amd64.tar.gz
    128e9d0ae6b6859bd5fc78b4cdfa6870  webhook-windows-arm.tar.gz
    7eb1170ace3d022fcde0afc6ede4293a  webhook-darwin-386.tar.gz
    cb663f8737f6d37f0cfc8c807a82c461  webhook-darwin-amd64.tar.gz
    7c6ced117b7fd8b3796f36e18375f8f3  webhook-freebsd-386.tar.gz
    85bdebd6e3ff2c4ce887e80d93e14980  webhook-freebsd-amd64.tar.gz
    2702575c0a6b0850ce58feb1df1d9c4c  webhook-freebsd-arm64.tar.gz
    27088b17d4492bf66c76f0841fb9b7bf  webhook-freebsd-arm.tar.gz
    31d002e9fdd2e01c87c58cc7f11e4ebf  webhook-linux-386.tar.gz
    62ab801c7337a8b83de8d6ae8d7ace81  webhook-linux-amd64.tar.gz
    2fa7f6327e83448f253dc1508aa51d72  webhook-linux-arm64.tar.gz
    aa87709d247c812806bdf9bbaa8ea024  webhook-linux-arm.tar.gz
    7667d92e321f09348884c4202d858ac5  webhook-openbsd-386.tar.gz
    1c5724643f8243c510abfa273ee29b9b  webhook-openbsd-amd64.tar.gz
    aff01500e6404d1834d6f6cca26d9de4  webhook-openbsd-arm64.tar.gz
    5ad72a10457a76ea05f0f613a34cb86f  webhook-openbsd-arm.tar.gz
    
  5. 2.7.0webhook 2.7.02020-05-12 · 2020-05-12 17:20 UTC
    查看更新说明

    Notice

    Switched to Go modules.

    Enhancements

    • Added support for multipart/form content encoding #373
    • Added XML payload support #376
    • Added SIGHUP support #378
    • Added setuid and setgid options for dropping privileges for platforms that are supported by Go #379
    • Added HTTP method verb whitelist filter #380
    • Added logfile support #381
    • Added pidfile support #383
    • Added debug info to show failed parameter lookup nodes in logs #384
    • Added support for comma-separated signatures to support secret rolling #388

    Bugfixes

    • Add request ID logging on missing command #415

    Binaries

    I've attached binaries that I've managed to cross-compile without problems.

    MD5 checksums

    931f46e10d34dc11bcd41290ce961a1c  webhook-darwin-386.tar.gz
    ffef29ad1f57d0246a760b55681c4d34  webhook-darwin-amd64.tar.gz
    ce08cade66a86fd156da349ae08c308e  webhook-freebsd-386.tar.gz
    aab2892803731e5fd57d873f207a5fee  webhook-freebsd-amd64.tar.gz
    85c47614dd0c33786ac02a9a959cb4d2  webhook-freebsd-arm64.tar.gz
    ee097256fa43dfbb779b9097233a0d69  webhook-freebsd-arm.tar.gz
    ac8642513a099837c38a35756b1c00a0  webhook-linux-386.tar.gz
    8bb63914f4ead672ff43191e91b0249f  webhook-linux-amd64.tar.gz
    7fa3fe7e130886af764d17a96e80f65b  webhook-linux-arm64.tar.gz
    8a7c241b34988ea80d1760c5724a3f5f  webhook-linux-arm.tar.gz
    ce25f0cde91e0707a94c7df1f3efb725  webhook-openbsd-386.tar.gz
    0312b8c65f3a7698bc1492bd4122ec52  webhook-openbsd-amd64.tar.gz
    991a8bef00c8eee345ec34fbd5d74557  webhook-openbsd-arm64.tar.gz
    703efef8523804523abbe0bea8012ce5  webhook-openbsd-arm.tar.gz
    5264c9da2abf7fbf6bc29505ebfc06af  webhook-windows-386.tar.gz
    67c7237613e7e0d414c29f621b1c8cef  webhook-windows-amd64.tar.gz
    7e3f0a81870bdf5dc9280a438c0271a0  webhook-windows-arm.tar.gz
    

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    What is webhook? build-status

    webhook is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands. You can also pass data from the HTTP request (such as headers, payload or query variables) to your commands. webhook also allows you to specify rules which have to be satisfied in order for the hook to be triggered.

    For example, if you're using Github or Bitbucket, you can use webhook to set up a hook that runs a redeploy script for your project on your staging server, whenever you push changes to the master branch of your project.

    If you use Mattermost or Slack, you can set up an "Outgoing webhook integration" or "Slash command" to run various commands on your server, which can then report back directly to you or your channels using the "Incoming webhook integrations", or the appropriate response body.

    webhook aims to do nothing more than it should do, and that is:

    1. receive the request,
    2. parse the headers, payload and query variables,
    3. check if the specified rules for the hook are satisfied,
    4. and finally, pass the specified arguments to the specified command via command line arguments or via environment variables.

    Everything else is the responsibility of the command's author.

    Not what you're looking for?

    Scriptable webhook gateway to safely run your custom builds, deploys, and proxy scripts on your servers.An event gateway to reliably ingest, verify, queue, transform, filter, inspect, monitor, and replay webhooks.

    Getting started

    Installation

    Building from source

    To get started, first make sure you've properly set up your Go 1.21 or newer environment and then run

    $ go build github.com/adnanh/webhook
    

    to build the latest version of the webhook.

    Using package manager

    Snap store

    Get it from the Snap Store

    Ubuntu

    If you are using Ubuntu linux (17.04 or later), you can install webhook using sudo apt-get install webhook which will install community packaged version.

    Debian

    If you are using Debian linux ("stretch" or later), you can install webhook using sudo apt-get install webhook which will install community packaged version (thanks @freeekanayaka) from https://packages.debian.org/sid/webhook

    FreeBSD

    If you are using FreeBSD, you can install webhook using pkg install webhook.

    Download prebuilt binaries

    Prebuilt binaries for different architectures are available at GitHub Releases.

    Configuration

    Next step is to define some hooks you want webhook to serve. webhook supports JSON or YAML configuration files, but we'll focus primarily on JSON in the following example. Begin by creating an empty file named hooks.json. This file will contain an array of hooks the webhook will serve. Check Hook definition page to see the detailed description of what properties a hook can contain, and how to use them.

    Let's define a simple hook named redeploy-webhook that will run a redeploy script located in /var/scripts/redeploy.sh. Make sure that your bash script has #!/bin/sh shebang on top.

    Our hooks.json file will now look like this:

    [
      {
        "id": "redeploy-webhook",
        "execute-command": "/var/scripts/redeploy.sh",
        "command-working-directory": "/var/webhook"
      }
    ]
    

    NOTE: If you prefer YAML, the equivalent hooks.yaml file would be:

    - id: redeploy-webhook
      execute-command: "/var/scripts/redeploy.sh"
      command-working-directory: "/var/webhook"
    

    You can now run webhook using

    $ /path/to/webhook -hooks hooks.json -verbose
    

    It will start up on default port 9000 and will provide you with one HTTP endpoint

    http://yourserver:9000/hooks/redeploy-webhook
    

    Check webhook parameters page to see how to override the ip, port and other settings such as hook hotreload, verbose output, etc, when starting the webhook.

    By performing a simple HTTP GET or POST request to that endpoint, your specified redeploy script would be executed. Neat!

    However, hook defined like that could pose a security threat to your system, because anyone who knows your endpoint, can send a request and execute your command. To prevent that, you can use the "trigger-rule" property for your hook, to specify the exact circumstances under which the hook would be triggered. For example, you can use them to add a secret that you must supply as a parameter in order to successfully trigger the hook. Please check out the Hook rules page for detailed list of available rules and their usage.

    Multipart Form Data

    webhook provides limited support the parsing of multipart form data. Multipart form data can contain two types of parts: values and files. All form values are automatically added to the payload scope. Use the parse-parameters-as-json settings to parse a given value as JSON. All files are ignored unless they match one of the following criteria:

    1. The Content-Type header is application/json.
    2. The part is named in the parse-parameters-as-json setting.

    In either case, the given file part will be parsed as JSON and added to the payload map.

    Templates

    webhook can parse the hooks configuration file as a Go template when given the -template CLI parameter. See the Templates page for more details on template usage.

    Using HTTPS

    webhook by default serves hooks using http. If you want webhook to serve secure content using https, you can use the -secure flag while starting webhook. Files containing a certificate and matching private key for the server must be provided using the -cert /path/to/cert.pem and -key /path/to/key.pem flags. If the certificate is signed by a certificate authority, the cert file should be the concatenation of the server's certificate followed by the CA's certificate.

    TLS version and cipher suite selection flags are available from the command line. To list available cipher suites, use the -list-cipher-suites flag. The -tls-min-version flag can be used with -list-cipher-suites.

    Running behind a reverse proxy

    webhook may be run behind a "reverse proxy" - another web-facing server such as Apache httpd or Nginx that accepts requests from clients and forwards them on to [webhook][h]. You can have webhook listen on a regular TCP port or on a Unix domain socket (with the -socket flag), then configure your proxy to send requests for a specific host name or sub-path over that port or socket to webhook.

    Note that when running in this mode the ip-whitelist trigger rule will not work as expected, since it will be checking the address of the proxy, not the client. Client IP restrictions will need to be enforced within the proxy, before it decides whether to forward the request to webhook.

    CORS Headers

    If you want to set CORS headers, you can use the -header name=value flag while starting webhook to set the appropriate CORS headers that will be returned with each response.

    Running under systemd

    On platforms that use systemd, webhook supports the socket activation mechanism. If webhook detects that it has been launched from a systemd-managed socket it will automatically use that instead of opening its own listening port. See the systemd page for full details.

    Interested in running webhook inside of a Docker container?

    You can use one of the following Docker images, or create your own (please read this discussion):

    Examples

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

    Guides featuring webhook

    Community Contributions

    See the webhook-contrib repository for a collections of tools and helpers related to webhook that have been contributed by the webhook community.

    Need help?

    Check out existing issues to see if someone else also had the same problem, or open a new one.

    Support active development

    Sponsors

    DigitalOcean is a simple and robust cloud computing platform, designed for developers.

    BrowserStack is a cloud-based cross-browser testing tool that enables developers to test their websites across various browsers on different operating systems and mobile devices, without requiring users to install virtual machines, devices or emulators.


    Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

    By contributing

    This project exists thanks to all the people who contribute. Contribute!.

    By giving money


    Thank you to all our backers!

    License

    The MIT License (MIT)

    Copyright (c) 2015 Adnan Hajdarevic [email protected]

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.