I am using Adpatavist ScriptRunner.
I want to get the email address of whoever raised a pull request, as part of an Event Handler (so it can be sent on to Jenkins)
This is the code I have got to:
PullRequestOpenRequestedEvent event = (PullRequestOpenRequestedEvent)event
def pullRequest=event.getPullRequest()
def email = pullRequest.getAuthor().getUser().getEmailAddress()
If I just look a the pull request in JSON via the API I can see the email address I want to get
"author": {
"user": {
"name": "myname",
"emailAddress": "myname@test.com",
However, when I do this I get the following error in the logs:
192.168.1.1,127.0.0.1 "POST /projects/XXX/repos/YYY/pull-requests HTTP/1.1" c.o.s.b.DynamicEventListenerInvoker Event handler failed: event: com.atlassian.bitbucket.event.pull.PullRequestOpenRequestedEvent file: <inline script>
java.lang.IllegalStateException: Pull request author could not be found in its participants
at com.atlassian.stash.internal.pull.InternalPullRequest.getAuthor(InternalPullRequest.java:192)
at com.atlassian.bitbucket.pull.PullRequest$getAuthor.call(Unknown Source)
at Script937.run(Script937.groovy:20)
Participants is an empty object in the API, and never seems to have anything in it (even when I add reviewers etc)
Am I just missing something fundamental with the API calls? Is my Bitbucket server configured incorrectly?
Any ideas appreciated
For anyone else who happens across this, I had the location of getUser within the API incorrect, I got it working using the following:
PullRequestOpenEvent event = (PullRequestOpenEvent)event
def email = event.getUser().getEmailAddress()
Hi @Josh Berry
Hope you are doing well.
I am looking to update/set the pull request merge commit author as the Original author (pull request open author or developer).
Usually, the developer who (he/she) worked on the branch will open the pull request and add the reviewers (senior developer/ team lead) to review the pull request changes. Once reviewer reviews or accepts the changes and merge the pull request to Master branch with commit message but the commit author will set as reviewer (because he/she is the one who commit).
So my question is here ...i want to set the pull request merge commit author should set to teh open pull request author.
I am able to get the autoer details using the PullRequestMergeEvent so now i want to compare it to original author and then set it.
Do you have any sample script code to update the pull request commit?
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josh,
to be able to obtain an email address of a pull request author, you have to send GET request to URL: /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}
According to log it seems to me, that you are sending POST request and also there is no pull request id in the url.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, GET vs POST might be the bit of information I was missing. Thanks very much, a new path to go down
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.