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

Is there a way to hide a button depending on the ChangeSet?

Open MushuEE opened this issue 6 years ago • 7 comments

I want to add buttons to kick a Jenkins Job that will build and Publish an rpm package. However, if the repo changes in Bitbucket do not have changes to the packaging/ sub directory... I do not want to show the button as an option. Triggering that build job would be meaningless for the 99% of PRs that do not have that change set. Is there a way to have a script run that will hide the button if it doesn't find the required changes?

MushuEE avatar Jun 06 '19 20:06 MushuEE

Can we disable the button if the pull request is not approved? Use case : we have added a sanity button to trigger some tests and we want this button to be enabled only if the pull request is approved.Is it feasible?

mkjkec2005 avatar Aug 14 '19 14:08 mkjkec2005

@mkjkec2005 yes by setting the filter text to ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} and the filter regexp to ^[^0]+?.

tomasbjerre avatar Aug 14 '19 14:08 tomasbjerre

I have 2 buttons to run UT and sanity and each of the button trigger a specific Jenkins job . For sanity button , i have already configured Filter string as ${BUTTON_TRIGGER_TITLE} and Filter regexp as "Sanity" ( title of the button) . Can i still use the mechanism you suggested to keep the button disabled if PR is not approved ? Note: We are using plugin version 3.24 and BB version is 5.14.1

mkjkec2005 avatar Aug 14 '19 15:08 mkjkec2005

Yes. You can have several variables in the filter text ${BUTTON_TRIGGER_TITLE}${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}. And the regrxp would be Sanity[^0]+?

tomasbjerre avatar Aug 14 '19 15:08 tomasbjerre

Thank you so much . This is Awesome !!

mkjkec2005 avatar Aug 14 '19 16:08 mkjkec2005

Can we also link this button to failed build ? For instance , i want to hide the button if the pull request has failed build ? My pull request is linked to 2 jobs - unit test and sanity. If unit test fails , i want to hide sanity button. So in summary , sanity button should be visible only if pull request is approved and has 1 successful build.

mkjkec2005 avatar Jan 18 '20 10:01 mkjkec2005

Can i also filter based on the comment text ? I tried ${PULL_REQUEST_COMMENT_TEXT} but it is coming as empty string.

Current regex (working fine for showing sanity button only if we have approval by default reviewers) ${BUTTON_TRIGGER_TITLE}${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME}

Since the requirement is to attach it with build status , i was planning to post a comment to PR if build is successful and use the comment text to filter the Sanity button. Please let me know if this is fine or we have a better alternative.

This is the only requirement pending and other than this the plugin works exceptionally well. Thanks again!

mkjkec2005 avatar Feb 10 '20 17:02 mkjkec2005