adnanh / webhook

webhook is a lightweight incoming webhook server to run shell commands
MIT License
10.34k stars 828 forks source link

Usage with gitea #453

Closed gedw99 closed 4 years ago

gedw99 commented 4 years ago

Is this working with gitea ?

I want to run gitea on the same server as this and when a web hook is received from Gita to then run a make file target on my code.

Then push the makefile output to an email to I can see what happened.

Thanks !

eleksir commented 4 years ago

Yup, it is definely working. I 've got this chain working. You need something like this as hooks.json:

[
  {
    "id": "webhook",
    "execute-command": "/var/lib/laminar/wrapper.pl",
    "command-working-directory": "/var/lib/laminar",
    "pass-environment-to-command":
    [
      {
        "source": "payload",
        "envname": "git_username",
        "name": "pusher.username"
      },
      {
        "source": "payload",
        "envname": "git_login",
        "name": "pusher.login"
      },
      {
        "source": "payload",
        "envname": "git_email",
        "name": "pusher.email"
      },
      {
        "source": "payload",
        "envname": "git_repo",
        "name": "repository.name"
      },
      {
        "source": "payload",
        "envname": "git_before",
        "name": "before"
      },
      {
        "source": "payload",
        "envname": "git_after",
        "name": "after"
      },
      {
        "source": "payload",
        "envname": "git_repository_full_name",
        "name": "repository.full_name"
      }
    ],
    "trigger-rule":
    {
      "and":
      [
        {
          "match":
          {
            "type": "value",
            "value": "my_token",
            "parameter":
            {
              "source": "url",
              "name": "token"
            }
          }
        },
        {
          "match":
          {
            "type": "value",
            "value": "refs/heads/master",
            "parameter":
            {
              "source": "payload",
              "name": "ref"
            }
          }
        }
      ]
    }
  }
]

and setup hook in gitea itself http://127.0.0.1:9080/hooks/webhook?token=my_token It is described in docs.

gedw99 commented 4 years ago

thanks @eleksir - awesome !!

gedw99 commented 4 years ago

works like a charm - awesome lib !!