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
404 stars 159 forks source link

Interpolate variables contributed within regexpFilterExpression #248

Closed kgluszczyk closed 1 year ago

kgluszczyk commented 1 year ago

Variables used within regexpFilterExpression are not interpolated. This change mimic the existing regexpFilterText interpolation which extends the number cases covered by the plugin.

tomasbjerre commented 1 year ago

What is the use case? What can you do with this patch, that you cannot do without it? Also provide a test case for that.

kgluszczyk commented 1 year ago

Within the Multibranch Pipeline project, we use that feature to trigger sanity build when a feature -> dev PR is created. We can not hardcode that as the branch name is dynamic and we need to trigger only the build on the source branch. Another example is to trigger a build for the PR destination branch on merge.

gwt-regex-filter-expression-variable-interpolation-use-case

tomasbjerre commented 1 year ago

I might be missing something, but is it not samme effect as this config?

regexpFilterExpression: "${env.BRANCH_NAME} MERGED",
regexpFilterText: "\$branch_to \$pr_state",
kgluszczyk commented 1 year ago

The screenshot above was a bit misleading. If we consider both events separately then yes, we could swap them. The problematic part is when we have both triggers configured. We would need to determine if $branch_from or $branch_to should be interpolated conditionally after the variables are evaluated. gwt-interpolation-example-2

tomasbjerre commented 1 year ago

I did not test this, but is that not samme effect as this config?

regexpFilterExpression: "(.* development pr:merged)|(development .* pr:opened)",
regexpFilterText: "\$branch_from \$branch_to \$pr_state",

image

kgluszczyk commented 1 year ago

@tomasbjerre you're absolutely right, thanks for giving it a fresh look 😎