monitorjbl / pr-harmony

Extra pull request workflows for Stash
GNU General Public License v3.0
33 stars 17 forks source link

PR Harmony does not work with Script Runner plugin #40

Open stoleas opened 8 years ago

stoleas commented 8 years ago

Hi there's an issue in Bitbucket 4.3.2 where there is added Default Users and Required Users, however when you go to open a pull request the user list shows up briefly before disappearing the reviewers do not get populated at all by default.

2016-04-05 09_44_08-pr harmony configuration - stash engineering - dev1 2016-04-05 09_44_56-create pull request sandbox _ edquail-test - stash engineering - dev1

monitorjbl commented 8 years ago

I'm not able to replicate this using version 4.3.0 or 4.3.2. Can you paste the console output from your browser when you try to open a PR? I suspect there's something weird going on either with another plugin or your environment.

stoleas commented 8 years ago

Hi monotorjbl, your speculation is correct. I disabled another plugin we recently installed called Script Runner from Adaptavist. https://marketplace.atlassian.com/plugins/com.onresolve.stash.groovy.groovyrunner/server/overview

Will upload the console output with the Script Runner plugin enabled. If it's not a simple fix or could impact your user base I can open a defect with the vendor.

POST https://bitbucket-dev1/bitbucket/rest/build-status/latest/commits/stats

200 OK
    69ms  
batch.j...e=en-US (line 29)
HeadersPostResponseJSONCookies

{}

[PR Harmony]: Fetching PR Harmony configuration for SAND/test-test
batch.j...e=en-US (line 242)
GET https://bitbucket-dev1/bitbucket/rest/pr-harmony/1.0/users/SAND/test-test

200 OK
    85ms  
batch.j...e=en-US (line 29)
HeadersResponseJSONCookies

{"requiredReviews":1,"requiredReviewers":[{"slug":"user1","name":"user1 (user1)"},{"slug"
:"user2","name":"user2 (user2)"}],"defaultReviewers":[{"slug":"user1","name":"user1
 (user1)"},{"slug":"user2","name":"user2 (user2)"}]}

GET https://bitbucket-dev1/bitbucket/rest/s...orkzonetest&toRepoId=91&to=refs%2Fheads%2Fmaster

200 OK
    312ms 
batch.j...e=en-US (line 29)
ParamsHeadersResponseJSONCookies

{"mandatory":[],"suggested":[]}

[PR Harmony]: Loaded config Object { requiredReviews=1,  requiredReviewers=[2],  defaultReviewers=[2]}
batch.j...e=en-US (line 242)
[PR Harmony]: Adding user "user1" to reviewer list
batch.j...e=en-US (line 242)
[PR Harmony]: Adding user "user2" to reviewer list
batch.j...e=en-US (line 242)
[PR Harmony]: Enabling submit buttonConnection to localhost closed.
monitorjbl commented 8 years ago

This is a paid plugin, so I'm going to have a hard time debugging this in the future. However, I installed the free trial (I only get 30 days, and I can't re-up as it's bound to my Atlassian account) and it looks like it's entirely on the ScriptRunner side.

I set a breakpoint in the Select2 plugin that Atlassian uses to render the users select box and watched for all updates to it. Most of them come from PR Harmony but right after my plugin completes and loads the users, the stash-auto-reviewers.js file overwrites the contents of that box with its own set of blank reviewers. I'd wager that any plugin which attempts to set users in this way is going to be incompatible with PR Harmony. There's not a lot to be done if two different plugins both decide to update that box independently. One has to win, and it would appear that in this case ScriptRunner wins.

There's not a link to source code that I've seen, so I made a quick Gist of the client-side Javascript code that's causing the issue: https://gist.github.com/monitorjbl/1e5660860c2fc9e4d1ea4393ef83756f#file-stash-auto-reviewers-js-L38. Anyone can download the trial and see this in their browser for free, so hopefully pasting that bit of Javascript doesn't get me into trouble 😓

stoleas commented 8 years ago

I've provided Adaptavist your suggestion and code blurb, they've opened a bug on their side for this. https://productsupport.adaptavist.com/browse/SRBITB-113

carlmot commented 7 years ago

Any update on whether this was fixed? Cannot access the issue at Adaptavist support.