Hello,
We have an idea of creating a pre-receive hook handler using ScritpRunner, which would only allow a push (containing some specific entries in any commit), if there is a special entry in one of the commit messages within this push request.
With PreRepositoryHookCommitCallback I can read the changes content and a commit message, but only from within the current commit. Is there a way to access other commits from a specific push?
Here is a pseudocode of what we try to accomplish:
commitCallback =
new PreRepositoryHookCommitCallback() {
@Override
boolean onCommitAdded(@Nonnull CommitAddedDetails commitDetails) {
if (commit.refChanges.any( contains a string matching a pattern) && !allPushCommits.any( has a message containing a special entry) ){
resultBuilder.veto("not allowed")
return false
}
}
Hi @Tomasz_Kmiecik ,
As a first suggestion I would try storing the commits (or just the commit messages, if that is what you are interested in) inside a global list.
Then call the onEnd() method to process the list.
For details see the JavaDoc for PreRepositoryHookCommitCallback here: https://docs.atlassian.com/bitbucket-server/javadoc/6.6.1/spi/reference/com/atlassian/bitbucket/hook/repository/PreRepositoryHookCommitCallback.html
And it's parent class here: https://docs.atlassian.com/bitbucket-server/javadoc/6.6.3/spi/reference/com/atlassian/bitbucket/hook/repository/RepositoryHookCommitCallback.html
Please let me know if this helps?
Regards,
Robert Giddings,
Product Manager, Adaptavist
Hi @Robert Giddings _Adaptavist_
Thanks a lot for this suggestion. onEnd() method did the trick.
Kind regards,
Tomasz Kmiecik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.