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

Button not displaying on PRs which are merged

Open itay opened this issue 8 years ago • 45 comments

We have a trigger that is configured like this:

image

I can see the API returning it: image

However, it's not being rendered: image

Any idea what might be happening?

itay avatar Feb 14 '17 00:02 itay

Which version of Bitbucket Server is that?

tomasbjerre avatar Feb 14 '17 05:02 tomasbjerre

4.11.1

itay avatar Feb 14 '17 06:02 itay

No errors in the console tab of developer tools? Do you have other buttons that are working with 4.11.1?

tomasbjerre avatar Feb 14 '17 06:02 tomasbjerre

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 avatar Feb 15 '17 16:02 tomasbjerre

@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. screen shot 2017-02-16 at 12 06 46 pm

The button is not appearing for PRs that have been merged: screen shot 2017-02-16 at 12 05 28 pm

And I can also see the API returning the button data: screen shot 2017-02-16 at 12 10 11 pm

However, it is appearing for non-merged PRs: screen shot 2017-02-16 at 12 08 25 pm

ahadiwijaya avatar Feb 16 '17 20:02 ahadiwijaya

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 avatar Feb 16 '17 20:02 tomasbjerre

@tomasbjerre I believe the Webhook to Jenkins plugin has always been disabled for the repository - do you know what else could affect this?

ahadiwijaya avatar Feb 16 '17 20:02 ahadiwijaya

The "Trigger Notification" -button in your first screenshot, is that not from the Webhook to Jenkins plugin?

tomasbjerre avatar Feb 16 '17 20:02 tomasbjerre

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.

ahadiwijaya avatar Feb 16 '17 20:02 ahadiwijaya

Ok I will probably have some time to look at this tomorrow. Thanks for the info!

tomasbjerre avatar Feb 16 '17 21:02 tomasbjerre

Thanks @tomasbjerre !

ahadiwijaya avatar Feb 16 '17 21:02 ahadiwijaya

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?

tomasbjerre avatar Feb 17 '17 13:02 tomasbjerre

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?

tomasbjerre avatar Feb 17 '17 13:02 tomasbjerre

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?

tomasbjerre avatar Feb 17 '17 14:02 tomasbjerre

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.

tomasbjerre avatar Feb 18 '17 18:02 tomasbjerre

Hi,

On both cases, I see: screen shot 2017-02-21 at 10 32 05 am

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?

ahadiwijaya avatar Feb 21 '17 18:02 ahadiwijaya

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.

tomasbjerre avatar Feb 21 '17 19:02 tomasbjerre

:'( Sure, I'll keep you updated once I find someone and find out what happened. Thanks!

ahadiwijaya avatar Feb 21 '17 19:02 ahadiwijaya

@tomasbjerre I was trying to debug it, but Bitbucket minifies it automatically so it's basically impossible to debug on our production instance.

itay avatar Feb 21 '17 19:02 itay

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

tomasbjerre avatar Feb 21 '17 20:02 tomasbjerre

Also, perhaps you can add the un-minified version from your local filesystem:

https://developers.google.com/web/tools/setup/setup-workflow

tomasbjerre avatar Feb 22 '17 20:02 tomasbjerre

Unfortunately this is production system with over 1000 users - we can't mess with it :)

itay avatar Feb 22 '17 20:02 itay

But if you add local pr-buttontrigger.js it will only affect you.

tomasbjerre avatar Feb 22 '17 20:02 tomasbjerre

Ah, I misread it. We can give it a shot.

itay avatar Feb 22 '17 20:02 itay

@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 avatar Mar 06 '17 10:03 tomasbjerre

@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" } ]

aepfli avatar Mar 06 '17 10:03 aepfli

imho: is this "version" related... if so, maybe deactivate the version for others... so they wont get that problem!

aepfli avatar Mar 06 '17 10:03 aepfli

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.

tomasbjerre avatar Mar 06 '17 11:03 tomasbjerre

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!

aepfli avatar Mar 06 '17 11:03 aepfli

Great! Thanks :)

tomasbjerre avatar Mar 06 '17 11:03 tomasbjerre