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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get pull request creator / author as a smart value in Jira automation?

I am trying to have a rule wherein if the ticket isn't in the correct status when the pull request is created, a comment is added addressing the pull request creator to transition the ticket in correct status. However, I am unable to derive the name of the pull request creator using smart value tags. I tried {{pullRequest.creator}}, {{pullRequest.author}}, {{issue.development.pullRequest.creator}} and so on but with no success

2 answers

1 accepted

0 votes
Answer accepted
Alexis Robert Community Leader Jan 27, 2021

Hi @Meghanand Baraskar , 

 

I recently had the same issue with another question : https://community.atlassian.com/t5/Jira-Software-questions/Automation-Trigger-Who-Runs-Flow/qaq-p/1586669

The answer is : not possible yet, but there's a feature logged for this https://codebarrel.atlassian.net/browse/AUT-1997

 

Let me know if this helps, 

 

--Alexis

0 votes

It's a little ugly, but I think you could do a Web Request to get this.

You'd need to take your {{pullRequest.url}} and use some text manipulations to change it into the appropriate API call (depends on your Git server - you'd also have to set up a service account/token etc etc). For Bitbucket Server, this seemed to work:

$SERVER/rest/api/latest/projects/$PROJECT/repos/$YOURREPO/pull-requests/4

This returned a nice bit of JSON, and you would then be able access the User account, display name, and email thusly:

{{webhookResponse.body.author.user.name}}
{{webhookResponse.body.author.user.displayName}}
{{webhookResponse.body.author.user.emailAddress}}

Thank you @Darryl Lee for your response. I am however, not quite familiar with how to go about doing what you have suggested. We too are using Bitbucket but I don't know what I can do with the URL I get from {{pullRequest.url}}

Darryl Lee Community Leader Jan 28, 2021

Hi, sorry, I should have provided some references and a little more explanation.

What I'm cavalierly suggesting (without testing) is that you use the Send outgoing web request action to talk to the Bitbucket API which contains a call that should let you get information about a Pull Request.

The idea is that you'd take the {{pullRequest.url}} and use some of the Smart Value text functions to rewrite it into a URL that you could use to make a call to the the Bitbucket API to obtain the Author info.

So if {{pullRequest.url}} is this:

https://YOURSERVER/projects/YOURPROJECT/repos/YOURREPO/pull-requests/7

You could a use:

{{pullRequest.url.replace("/projects/","/rest/api/latest/projects/")}}

To get to:

https://YOURSERVER/rest/api/latest/projects/YOURPROJECT/repos/YOURREPO/pull-requests/4

So you would put that bit with the replace into the Webhook URL field.

The trick here is that to talk to your Bitbucket server, you'll need to be authenticated.

I found this old post that makes it sound like Basic Auth should work with username/password, but you really should instead create a Personal Access Token

ANYWAYS, once you set up a token, you'll follow steps similar to these:

Automation for Jira - Send web request using Jira REST API

But instead of the Jira REST API, you'll be talking to the Bitbucket API, again, using the generated URL above.

Here's another good reference to what we're trying to do here, although in this example, they don't need to deal with authentication:

Send Web Request Action now Provides Response Data 

Anyways, unfortunately this is all theoretical. I don't have any projects with active Pull Requests where I can test this kind of thing. Has anyone else ever done this in real life?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Automation

New to Jira Automation - goodbye Cron (sort of), hello new project created trigger, new additions to

Hey Everyone! Simeon from the Automation team here. I'm delighted to share some new features and improvements that we are shipping to Jira automation (Cloud only). Firstly, @Sam Harding&nbsp...

2,810 views 10 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you