Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching {{pullRequest.destinationBranch}}

Nareg Karamanoukian March 1, 2023

I am trying to access the {{pullRequest.destinationBranch}} smart value in my Jira automations.

Is there a way to manually trigger a rule to fetch the pull request info (for example the destination branch name)? I know it is mentioned here that these smart values are only accessible during the Pull request created, Pull request declined and Pull request merged triggers.

Is there any workaround?

1 answer

0 votes
Stefan Salzl
Community Champion
March 1, 2023

Hi @Nareg Karamanoukian 

General question:
What would be the requirement/use case behind that?

as already mentioned this information is linked to the special event of a PR. In case it is this important to grab that information later you could create a custom field and fill in the needed information (eg. destination branch) on PR. 

Another way could be (not sure about that but maybe worth giving it a shot) to call an API (eg. github Rest API) to retrieve that data via "send web request" action in A4J. I just dunno how to build the parameters/where to get the data from for the request.

 

Best
Stefan

Nareg Karamanoukian March 1, 2023

Thank you @Stefan Salzl for your input.

 

What I would like to do is to fetch the destination branch during state transitions.

 

I had considered saving in a custom field, however there is no "listener" for Pull Request modified action. Sometimes developers change the destination branch of the pull request, and I'm not sure how to reflect that change in Jira.

Stefan Salzl
Community Champion
March 2, 2023

Got it ;)

A kinda tricky solution that would also need some deeper configuration would be to work with webhooks inside your git solution. so eg. to send a webhook from github whenever a pull request is edited and an automation rule in jira grabs this webhook and updates your custom field with the information.

see a docu from github in the link below:
https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request

As mentioned above this needs deeper investigation and also research regarding the git solution u are using.

Hope I could still give some helpful input.

Best
Stefan

Nareg Karamanoukian March 3, 2023

Thanks.. no direct solution sadly. Hope this gets introduced soon.

Stefan Salzl
Community Champion
March 3, 2023

Hi @Nareg Karamanoukian 

I can´t talk for Atlassian and don´t know what they are planning. I just can´t imagine how this should be implemented so in my opinion chances are not very high there will be an out of the box solution.

To clarify my thoughts: imho this is more a question of the process. Why would the destination branch be changed? wouldn´t that be more accurate to decline the pull request and create a new one?

furthermore from the technical perspective: 
The system where the git stuff happens is a different one than jira. There is communication for the most relevant actions so far. For any other "custom" events there is the possibility to create custom webhooks (as described in my previous post). So there is a solution, it just needs to be done ;)

Best
Stefan

Like Nareg Karamanoukian likes this
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 12, 2023

Hi @Nareg Karamanoukian,

At the moment you'd need to do this yourself by sending a web hook to the repository API to fetch the info you're after.

Which Git provider are you using?

What are you storing about the pull request in order to be able to identify it?  

Nareg Karamanoukian March 14, 2023

Hello @Simmo ,

I am using GitLab as my Git provider.

Various automation rules (triggered during state transition or manually via Rules Executions) need the data related to the PR. For instance, in one of those manually triggered rules, depending on the destination branch fetched, web requests are sent to various Jenkins projects with the parameters read from the PR data.

In other words, if the destination branch is master branch, send a web request to URL_1; in case the destination branch is release, send another web request to URL_2

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2023

So there isn't anything for what you're after at the moment. You'll need to have the id of the Pr and fetch that information from Git using the send web request action I'm afraid.

Nareg Karamanoukian March 22, 2023

Yes, I hope the Atlassian team adds {{pullRequest.destinationBranch}} value during all the transitions in the upcoming Jira Automation updates.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events