pull-request-notifier-for-bitbucket
pull-request-notifier-for-bitbucket copied to clipboard
Button not displaying on PRs which are merged
We have a trigger that is configured like this:

I can see the API returning it:

However, it's not being rendered:

Any idea what might be happening?
Which version of Bitbucket Server is that?
4.11.1
No errors in the console tab of developer tools? Do you have other buttons that are working with 4.11.1?
Now I see it!
I just released 2.54 that changes the "state" label to "Ignore if". Which is what those 2 checkboxes does. They ignore the notification if the PR is merged/declined.
@tomasbjerre Was the fix just the label? I tried changing the configuration by unchecking the "State" (="Ignore if") conditions, and the issue still persists - the button is not appearing for merged PRs.

The button is not appearing for PRs that have been merged:

And I can also see the API returning the button data:

However, it is appearing for non-merged PRs:

Yes that was the only change.
Perhaps the problem is a conflict with the Webhook to Jenkins plugin. If you disable that plugin, does the button from this plugin show up correctly also for unmerged PR:s?
@tomasbjerre I believe the Webhook to Jenkins plugin has always been disabled for the repository - do you know what else could affect this?
The "Trigger Notification" -button in your first screenshot, is that not from the Webhook to Jenkins plugin?
I think it's from PR notifier (?) Please correct me if I'm wrong.
WebFragments.addWebItemDescriptor({"completeModuleKey":"se.bjurr.prnfs.pull-request-notifier-for-stash:se.bjurr.prnfb.triggerbutton","key":"se.bjurr.prnfb.triggerbutton","moduleKey":"se.bjurr.prnfb.triggerbutton","params":{},"pluginKey":"se.bjurr.prnfs.pull-request-notifier-for-stash","location":"bitbucket.internal.pullrequest.toolbar.deprecated/bitbucket.pull-request.toolbar.actions","weight":50,"linkText":"Trigger Notification","styleClass":"triggerManualNotification"});
This fragment appears both on the merged and non-merged PRs, but I only see it as a button on merged PRs.
Ok I will probably have some time to look at this tomorrow. Thanks for the info!
Thanks @tomasbjerre !
I just tried it with Webhook plugin and there is no conflict. It works for me.
And you have no errors in the console log? There are no invisible or space chars in your filter regexp or text?
I have configuration like this:
curl -u admin:admin 'http://localhost:7990/bitbucket/rest/prnfb-admin/1.0/settings/notifications' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01'
Gives:
[{"filterRegexp":"Build AMI","filterString":"${BUTTON_TRIGGER_TITLE}","headers":[],"method":"GET","name":"Notification","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://localhost:7990/bitbucket/plugins/servlet/prnfb/admin","uuid":"0ba1a2fb-c6e9-48c0-848e-72bde5597402","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"Notification","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["RESCOPED_FROM","RESCOPED_TO"],"url":"http://localhost:80/?abc","uuid":"b1306a3a-5a87-4145-80b7-660bc986dd25","postContentEncoding":"NONE"}]
curl -u admin:admin 'http://localhost:7990/bitbucket/rest/prnfb-admin/1.0/settings/buttons/repository/1/pullrequest/1' -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01'
Gives:
[{"buttonFormList":[],"buttonFormListString":"[]","name":"Build AMI","uuid":"54fa6576-1dd2-4443-989e-bdb6ca3a238c"}]
And that button is also shown in GUI. What do you get with these curl commands?
I read this issue a bit to quick. It must be a frontend issue. Very hard to investigate unless there is an error in the console view of Developer Tools. Any other plugins you have installed that might cause it?
The "Trigger Notification" is added here: https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/main/resources/atlassian-plugin.xml#L59
It is just a placeholder that should be removed immediately when the page loads: https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/blob/master/src/main/resources/pr-triggerbutton.js#L208
If is not removed, I would suspect that:
- The javascript was never loaded, do you see in the resources tab in Developer Tools?
- Or that it crashed, that should be clear from the console tab in Developer Tools.
Hi,
On both cases, I see:

On the error console, I do not see any error corresponding to pr-triggerbutton resources. Does this imply that the function that executes the generation of the buttons on the UI was never called?
Strange... Do you have anyone there who knows some Javascript and can debug it? the pr-triggerbutton.js is not minified and can be debugged.
It should find a button, the one called "Trigger Button", remove it and add new buttons in its place.
:'( Sure, I'll keep you updated once I find someone and find out what happened. Thanks!
@tomasbjerre I was trying to debug it, but Bitbucket minifies it automatically so it's basically impossible to debug on our production instance.
Thanks for trying @itay =)
Maby try -Datlassian.webresource.disable.minification=true
https://developer.atlassian.com/docs/advanced-topics/supporting-minification-of-javascript-and-css-resources
Also, perhaps you can add the un-minified version from your local filesystem:
https://developers.google.com/web/tools/setup/setup-workflow
Unfortunately this is production system with over 1000 users - we can't mess with it :)
But if you add local pr-buttontrigger.js it will only affect you.
Ah, I misread it. We can give it a shot.
@aepfli Are your buttons returned from the rest-service? Did you also install/update any other plugin when moving from 2.55 to 2.57?
@tomasbjerre besides the workzone plugin - this was the only plugin we updated!
buttons REST CALL
[ { "buttonFormList": [], "buttonFormListString": "[]", "name": "trigger FeatureBuild", "projectKey": "****", "repositorySlug": "****", "userLevel": "EVERYONE", "uuid": "1f3d6cf3-fd62-4335-b28d-24b70471d5cb", "confirmationText": "Build has been Triggered! dont hit the button twice" } ]
imho: is this "version" related... if so, maybe deactivate the version for others... so they wont get that problem!
If I understand correctly. @itay had the problem in 2.53. @aepfli had it working in 2.55.
But that is something you can do to help. Try older versions and try to identify one introducing the problem.
i am right now getting a frontend dev.. to take a look with me... but, we also just use the minified version, as we cant switch for 500 users atm... also i will issue a restart of stash at night... maybe the old "quick fix" will help :D
but i will come back to this topic!
Great! Thanks :)