Webhook: Usage with gitea

Created on 29 Aug 2020  路  3Comments  路  Source: adnanh/webhook

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 !

question

Most helpful comment

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.

All 3 comments

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.

thanks @eleksir - awesome !!

works like a charm - awesome lib !!

Was this page helpful?
0 / 5 - 0 ratings