Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Check whether source branch has fallen behind target branch

Sascha SK August 2, 2021

Hello,

my company is using Bitbucket Server v6.10.5 with ScriptRunner for Bitbucket v6.6.0.

I would like to create a "Conditional merge check" based on the accepted answer from this post:
https://community.atlassian.com/t5/Answers-Developer-Questions/Validate-PullRequest/qaq-p/536378

My goal is simply to check whether the source branch of an open pull request has maybe already fallen behind the target branch and if so, disable the merge button with a custom veto message.

When I use the code provided in the answer from the link above, I always get the error message: "unable to resolve class com.onresolve.scriptrunner.canned.bitbucket.pullrequests.PullRequestPolicies".

Unbenannt.JPG

Is anyone able to explain that error and/or how the solution needs to be adjusted so that it works for me?

Thanks a lot in advance
Sascha

1 answer

1 accepted

0 votes
Answer accepted
Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 3, 2021

Hi @Sascha SK ,

ScriptRunner for Bitbucket now comes with a Built-In Merge Check for doing exactly that.

Please view the docs here, for info on the "Prevent Merge of Pull Requests Behind Target Branch" Built-In Merge Check: 

https://docs.adaptavist.com/sr4bib/latest/features/script-merge-checks/built-in-merge-checks/prevent-merge-of-pull-requests-behind-target-branch

However you will need to update to at least ScriptRunner for Bitbucket 6.28.0 in order to use it.

Please let me know if this works for you, without needing to write your own custom script?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Sascha SK August 3, 2021

Hi @Robert Giddings [Adaptavist] 

thanks a lot for your quick reply.

I will then request the required update to the version you mentioned (or higher) from the responsible team in my company and then let you know a bit later how it went.

Best regards
Sascha

Sascha SK October 13, 2021

Hi @Robert Giddings [Adaptavist] ,

just FYI, the update to the newer version went fine and the new merge check is indeed exactly what we wanted. Thanks again for the hint.

The only unfortunate thing is the predefined veto message which cannot be changed. It always says by default

Please rebase your branch on to the target branch before merging a pull request: git checkout develop; git pull; git checkout feature/<branch-name>; git rebase develop; git push --force-with-lease

although even in the ScriptRunner docs it is mentioned that this is only one of the two solutions besides just merging the target branch into the source branch (so without any rebase). Maybe this can be improved in future versions since it's confusing to developers if rebasing is not the approach that is aimed for.

Best regards
Sascha

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 13, 2021

Hi @Sascha SK ,

Thank you for your latest comment.

And custom merge check messages is something we are indeed planning to add to the product in the near future.

Kind regards,

Robert Giddings

Like Sascha SK likes this
Sascha SK October 15, 2021

Hi @Robert Giddings [Adaptavist] ,

after the first few days working with the hook mentioned above it turns out that the problem I described above (predefined veto message cannot be changed) is indeed quite critical for us since several developers - although they got a proper instruction - already got confused by it (we do not want to use rebasing but merging instead).

Do you see any chance to support me with the implementation of a "Conditional merge check" so I am able to add a custom veto message? I already gave that a try (see my very first post) but did not make it to get it running. Please also note that I am "only" admin as a Bitbucket user, so only able to access the ScriptRunner UI in my Bitbucket projects.

Thanks in advance and best regards
Sascha

Sascha SK November 9, 2021

@Robert Giddings [Adaptavist] ,

are you meanwhile able to give at least a rough time frame for the custom veta messages built in by default in the hook mentioned above?

And custom merge check messages is something we are indeed planning to add to the product in the near future.

Thanks in advance and best regards
Sascha

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 9, 2021

Hi @Sascha SK ,

We plan to release custom messages sometime in the next month. I hope you are able to hold on until then?

Kind regards,

Robert Giddings

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 7, 2021

Hi @Sascha SK ,

We should be releasing an improvement to this merge-check's default message in the next ScriptRunner for Bitbucket release in about a weeks time.

Kind regards,

Robert Giddings

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 21, 2021

Hi @Sascha SK ,

We have now released a new version of ScriptRunner for Bitbucket with a more generalised Merge-Check message.

Please see the Release Notes for ScriptRunner for Bitbucket 6.41.0, for more details: https://docs.adaptavist.com/sr4bib/6.41.0/release-notes/release-6-x#id-.Release6.xv6.41.0

Please let me know if this helps resolve the issue previously reported above?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Sascha SK December 21, 2021

@Robert Giddings [Adaptavist] ,

thanks a lot for letting me know. Unfortunately, I have to admit that I'm a bit disappointed of this change. 

The corresponding ticket at https://productsupport.adaptavist.com/browse/SRBITB-1063 is correctly saying

This could confuse developers from teams that prefer following the merge strategy.

and instead of offering a custom veto message like with other already existing hooks (and like discussed in this conversation here), the already confusing default veto message was now just changed to yet another confusing default veto message. 

If my project only follows the merge strategy, it's still confusing to developers if both solutions (merging and rebasing) are offered in the message as equal alternatives. Instead, I would have loved to define a custom message saying "...please merge..." without mentioning rebasing only a bit.

Anyway, thanks again for letting me know and maybe there will be another change of this hook in the future with a real custom veto message.

Best regards
Sascha

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2021

Hi @Sascha SK ,

Thank you for your feedback.

Yes, the original intention was to make the message completely customisable. However, there are a few things we need to consider to make that work completely as expected.

So, in the meantime, we decided to make the error message more generic.

Given the above feedback, one possible improvement, prior to a completely custom message, might be to have a checkbox for selecting which of the two current messages you wanted?

We will look further into this.

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Sascha SK December 22, 2021

Hi @Robert Giddings [Adaptavist] ,

thanks for your understanding and the explanation of the reasons.

If you really want to implement such an intermediate solution as described by you above, it would of course be very helpful if all three potential messages (only merging, only rebasing, both as equal alternatives) are also offered via checkbox(es)/dropdown(s)/etc.

Something like that would definitely be helpful to cover the time until a real custom veto message is available in that hook.

Best regards
Sascha

Robert Giddings [Adaptavist]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 20, 2022

Hi @Sascha SK ,

I wanted to let you know that the latest version of ScriptRunner for Bitbucket, version 6.49.0, now has the option to configure which message will be displayed to users.

I.e. either telling the users to merge, or rebase, or that the users can do either.

Please let me know if this helps improve your development workflow?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket

Sascha SK April 22, 2022

Hi @Robert Giddings [Adaptavist] ,

thanks a lot for letting me know. I requested the version update with my IT and try to give it a try asap. It definitely sounds very promising ;-)

Best regards
Sascha

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events