jenkinsci / generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
https://plugins.jenkins.io/generic-webhook-trigger
411 stars 162 forks source link

Ability to add more optional filters to run the job based on OR operations of two AND operations. #136

Closed avatsyain closed 5 years ago

avatsyain commented 5 years ago

I have two variables action and merged.

possible values of action ^(reopened|opened|closed|synchronize)$ possible value of merged ^(true|false)$

I want the job to be triggered only when

  1. {"action": "opened", "merged":false}
  2. {"action": "reopened", "merged":false}
  3. {"action": "synchronize", "merged":false}
  4. {"action": "closed", "merged":true}

The job shouldn't be triggered except above scenarios.

tomasbjerre commented 5 years ago

This should work:

Filter text: $action $merged Filter regexp: ^opened false$|^reopened false$|^synchronize false$|^closed true$

https://jex.im/regulex/#!flags=&re=%5Eopened%20false%24%7C%5Ereopened%20false%24%7C%5Esynchronize%20false%24%7C%5Eclosed%20true%24

See also example here: https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd/filter-on-multiple-variables.feature