pull-request-notifier-for-bitbucket icon indicating copy to clipboard operation
pull-request-notifier-for-bitbucket copied to clipboard

Using filterString and filterRegexp

Open skarfiol opened this issue 7 years ago • 17 comments

Hi,

I'd like to implement a notification which is only started, when the ${PULL_REQUEST_TO_BRANCH} is a specific branch of my repository. E.g. to send notifications of all PRs to the master branch for example.

I guess this is fairly simple, but I can't get my head around the filterString and filterRegexp fields from the docs.

Please help, many thanks in advance. Regards, Andras

skarfiol avatar Jan 15 '18 13:01 skarfiol

Let the filter string be ${PULL_REQUEST_TO_BRANCH} and the filter regexp be master.

tomasbjerre avatar Jan 15 '18 13:01 tomasbjerre

Awesome, thanks for the super-fast answer!

skarfiol avatar Jan 15 '18 13:01 skarfiol

Perhaps you need regexp to be ^master$... there is a test case here: https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/test/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListenerTest.java#L378

tomasbjerre avatar Jan 15 '18 13:01 tomasbjerre

Hi, I have a similar question related to filter and regexp. I would like to have notification which is triggered when ${PULL_REQUEST_TO_BRANCH} = develop or master, and additionally, there should be the possibility to trigger the notification by pressing the button.

I suppose it should be something like that:

Filter string: ${PULL_REQUEST_TO_BRANCH}${BUTTON_TRIGGER_TITLE} Filter regexp: ^(develop|master)$|

I tried different ways, but couldn't combine those two conditions.

Could you please help with that?

asuprunevich avatar Mar 15 '18 10:03 asuprunevich

Any button or a specific one?

Filter string: ${PULL_REQUEST_TO_BRANCH}_${BUTTON_TRIGGER_TITLE}_ Filter regexp: ^(develop|master)_.+_$ or ^(develop|master)(?!__$) If it is a specific button, the filter regexp can be perhaps ^(develop|master)_That button name_$

tomasbjerre avatar Mar 15 '18 11:03 tomasbjerre

Thanks for quick answer. I would like to have the specific button for notification. Button name: build-pr

After setting it:

Filter string: ${PULL_REQUEST_TO_BRANCH}${BUTTON_TRIGGER_TITLE} Filter regexp: ^(develop|master)build-pr$

the button has appeared, but the build wasn't triggered automatically when I created PR.

asuprunevich avatar Mar 15 '18 12:03 asuprunevich

Ok. With filter string like ${PULL_REQUEST_TO_BRANCH}_${BUTTON_TRIGGER_TITLE}_ this should work ^(develop|master)(_build-pr_|__)$

tomasbjerre avatar Mar 15 '18 13:03 tomasbjerre

It works now. Thanks a lot! The button has appeared in the pr context menu, but I see some strange empty lines there:

image Do you know the reason?

asuprunevich avatar Mar 15 '18 16:03 asuprunevich

No not sure why that happens. You only have one button configured right?

tomasbjerre avatar Mar 15 '18 16:03 tomasbjerre

Yes, only one, at least for this particular repository.

asuprunevich avatar Mar 15 '18 17:03 asuprunevich

Hi,

I have similar issue, I would like to trigger Jenkins when ${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT} = 0, and ${PULL_REQUEST_TO_BRANCH} = master or release/*

how to set the filter?

VivianZhang1990 avatar May 15 '18 08:05 VivianZhang1990

This should work:

Filter: ${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT} ${PULL_REQUEST_TO_BRANCH}

Regexp: 0 (master|release/.*)

https://jex.im/regulex/#!flags=&re=0%20(master%7Crelease%2F.*)

tomasbjerre avatar May 15 '18 08:05 tomasbjerre

Hi, Thanks for the quick reply. I was faced with a new problem.How to fill Regexp with variables?

VivianZhang1990 avatar May 23 '18 06:05 VivianZhang1990

The regexp field does not support variables. Why do you need that?

tomasbjerre avatar May 23 '18 07:05 tomasbjerre

Hey @tomasbjerre , I see this conversation tailed off, but I am looking to use variables in the regexp field because I'm trying to only send a notification when the person clicking the button is not the author of the pull request itself.

Is there another way of achieving that functionality without using the regexp field?

jhill072 avatar Oct 16 '19 16:10 jhill072

Sounds like a valid use case.

tomasbjerre avatar Oct 16 '19 16:10 tomasbjerre

Hi,

I would like to trigger Jenkins when ${PULL_REQUEST_TO_BRANCH} = feature/ANZIDTPM-QA

how to set the filter?

abhilashbn93 avatar Mar 02 '21 13:03 abhilashbn93