简体   繁体   中英

How do I select parameters in a KRL webhook?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM