generic-webhook-trigger-plugin icon indicating copy to clipboard operation
generic-webhook-trigger-plugin copied to clipboard

Ability to view evaluated text and regex matches from Optional filter

Open petromir opened this issue 5 years ago • 9 comments

I have the following options:

Variables

Variable JSONPath Expression Value filter
$changed_dir_files $.commits[*].['modified','added','removed'][*] None
$ref $.ref ^(refs/heads/|refs/remotes/origin/)

Optional filter

Expression Text
master\s((.*"(books/|common/|sqs/|security/|common-test/|db/)[^"]+?".)|(."[^/"]+".*)) $ref $changed_files

Would it be possible to view the following Optional filter data within Jenkins (not only in the response of the request to https://<JENKINS_URL>/generic-webhook-trigger/invoke):

  1. Expression - same as in the response, e.g.
"regexpFilterExpression": "master\\s((.*\"(legal-values/|common/|sqs/|security/|common-test/|db/)[^\"]+?\".*)|(.*\"[^/\"]+\".*))"
  1. Evaluated text when variables are used in Text field, same as in the response
"regexpFilterText": "master [\"README.md\"]"
  1. Regex matches. It would help us to see what the given regex matches and why might not work.

petromir avatar Nov 27 '18 11:11 petromir

When you say "within Jenkins", do you mean the build log? So only for jobs that are triggered?

tomasbjerre avatar Nov 27 '18 11:11 tomasbjerre

The information can be presented in the build log, when the regex matches, but I don't know where the content goes when doesn't match.

petromir avatar Nov 27 '18 11:11 petromir

It can be logged to the global Jenkins log. And you would need access to that.

tomasbjerre avatar Nov 27 '18 11:11 tomasbjerre

The access is not an issue. I already have few log recorders for hooks:

screenshot 2018-11-27 at 14 08 46

Here is Github Pull Request Hook screenshot 2018-11-27 at 14 10 45

petromir avatar Nov 27 '18 12:11 petromir

Ok.

I think most users are able to invoke the Jenkins instance with curl. And will get a clear response from that.

The downside of implementing this is the risk of spamming logs. And it would probably require an extra checkbox in the GUI to enable/disable this logging.

So it would add some complexity that I don't feel is needed as you can do the same thing with curl.

tomasbjerre avatar Nov 27 '18 12:11 tomasbjerre

The response of curl doesn't print what has been matched. Regarding logs, you already have few checkboxes, so another one won't hurt anyone :), compared to the benefits.

petromir avatar Nov 27 '18 12:11 petromir

What about doing something similar to what the Multibranch Pipeline plugin does? Add an even log link that lists requests coming in and triggered jobs if any.

spidey avatar Jun 08 '21 08:06 spidey

Feel free to submit a PR.

tomasbjerre avatar Jun 08 '21 15:06 tomasbjerre

Well I don't use Jenkins anymore, so feel free to close this issue.

petromir avatar Jun 08 '21 15:06 petromir