webhook
webhook copied to clipboard
Same hook/id, multiple triggers/scripts
Hi, Thanks for creating this project.
One thing that I have tried is to have multiple triggers on the same endpoint.
I have configured one rule for each branch, so the endpoint can be the same, just the "ref"(branch) that changes.
So to be able to do this, I had to create 2 endpoints, but the info is the same, there is no need to have multiples ids,
So I have tried the same id duplicated on the conf file, but only one is hit.
I solved this by passing the ref to the script and doing it conditionally in the script
Yeah, we intentionally got rid of this functionality to simplify the hook handling logic. Like @classabbyamp said, it's best to handle it within the script itself.
BTW, would you mind sharing your config? Could it be done by combining those two rules with a simple "OR" rule?
In the future, I'm hoping to expand trigger rules to allow for arbitrary expressions.
Do you mean mine ?
{
"id": "redeploybackend",
"execute-command": "99_installbackend.sh",
"command-working-directory": "/opt/PO/SCRIPTS",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "head_commit.message"
},
{
"source": "payload",
"name": "pusher.name"
},
{
"source": "payload",
"name": "head_commit.id"
}
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hash-sha1",
"secret": "SECRET",
"parameter":
{
"source": "header",
"name": "X-Hub-Signature"
}
}
},
{
"match":
{
"type": "value",
"value": "refs/heads/release_backend",
"parameter":
{
"source": "payload",
"name": "ref"
}
}
}
]
}
},
{
"id": "redeployfrontend",
"execute-command": "99_installfrontend.sh",
"command-working-directory": "/opt/PO/SCRIPTS",
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "head_commit.message"
},
{
"source": "payload",
"name": "pusher.name"
},
{
"source": "payload",
"name": "head_commit.id"
}
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hash-sha1",
"secret": "SECRET",
"parameter":
{
"source": "header",
"name": "X-Hub-Signature"
}
}
},
{
"match":
{
"type": "value",
"value": "refs/heads/release_frontend",
"parameter":
{
"source": "payload",
"name": "ref"
}
}
}
]
}
}
]
I prefer to keep my bash script designed to front and back separated because in the future i will break on two different repositories.