I want to run some KRL rules when a website is updated. The deploy script will get the following URL after pushing the updates:
http://webhooks.kynetxapps.net/t/_appid_/updated?site=production&version=123456abcdef
The ruleset to handle this webhook starts out like this:
rule site_updated {
select when webhook updated
pre {
site = event:param("site");
version = event:param("version");
}
// do something with site and version
}
From http://docs.kynetx.com/docs/Event_API I could make more specific rules with:
select when webhook updated site "test"
or webhook updated site "production"
Is there a way to get both parameters without a PRE block? What is the best way to use SELECT with a webhook?
Rule filters (like site "test") are regular expressions, and you can set variables using the setting () clause.
http://webhooks.kynetxapps.net/t/_appid_/update?site=production&version=123456abcdef
select when webhook update site "(.*)" setting(site)
causes site to be set to production without using a pre block. As this is a regular expression, you can match anything, like either of two options:
select when webhook update site "(test|production)" setting(site)
will only match with site == test or site == production, and no other times, AND store the value in the site variable in the context of the rule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With