mirror of
https://github.com/adnanh/webhook.git
synced 2025-10-06 06:31:02 +00:00
hookHandler: Bug with multiple hooks having the same ID
It was possible to have multiple hooks with the same ID, but the return in the for/if of the hookHandler method were stopping the loop, thus making it impossible to continue the executions of the other hooks. This isn't the behaviour expected because a service might be down, because you want to run more than one hook, or don't want to stop due to one that failed. This commit fixes it, and add tests associated. The hooks have been copied from the github one, slightly modified and spread in the template file. A "dummy" hook which is never called has also been added, just in case it could mess with some other, and a test for non existing hook has also been added to the tests. This PR fixes: https://github.com/adnanh/webhook/issues/76
This commit is contained in:
parent
18b0573bc4
commit
c3c7b5fc1a
3 changed files with 253 additions and 7 deletions
|
@ -53,6 +53,60 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "github-called-twice",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
"command-working-directory": "/",
|
||||
"include-command-output-in-response": true,
|
||||
"pass-environment-to-command":
|
||||
[
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "created"
|
||||
}
|
||||
],
|
||||
"pass-arguments-to-command":
|
||||
[
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "head_commit.id"
|
||||
},
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "repository.fork"
|
||||
}
|
||||
],
|
||||
"trigger-rule":
|
||||
{
|
||||
"and":
|
||||
[
|
||||
{
|
||||
"match":
|
||||
{
|
||||
"type": "payload-hash-sha1",
|
||||
"secret": "mysecret",
|
||||
"parameter":
|
||||
{
|
||||
"source": "header",
|
||||
"name": "X-Hub-Signature"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match":
|
||||
{
|
||||
"type": "value",
|
||||
"value": "refs/heads/master",
|
||||
"parameter":
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "ref"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bitbucket",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
|
@ -134,6 +188,39 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "uncalled-hook",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
"command-working-directory": "/",
|
||||
"include-command-output-in-response": true,
|
||||
"response-message": "success",
|
||||
"parse-parameters-as-json": [
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "payload"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "github-called-twice",
|
||||
"execute-command": "{{ .Hookecho }}",
|
||||
"command-working-directory": "/",
|
||||
"include-command-output-in-response": true,
|
||||
"pass-environment-to-command":
|
||||
[
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "pusher.email"
|
||||
}
|
||||
],
|
||||
"pass-arguments-to-command":
|
||||
[
|
||||
{
|
||||
"source": "payload",
|
||||
"name": "repository.created_at"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue