Forums

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

How to automate state transitions based on pull request ID?

Bogdan Kosanovic March 26, 2021

Hello,

I am new to JIRA automation. We use Cloud version. I have a project that is Classic, Scrum. (cloud version of JIRA)

I would like to create an automation rule that can move my issue from RESOLVED to CLOSED only if the pull request ID is identifying specific repository.

For example, I have two repositories that may contribute work for a single issue. REP-A and REP-B. I would like the issue to be moved from RESOLVED to CLOSED if and only if the pull request from REP-B was merged in. Pull requests from REP-A must not result in closing the issue.

I was thinking to try using pull request ID, but I do not know how to reference it within the automation rules and which rule components would be most appropriate to try using for this. For example, if/else block or some other. I would also need to "parse/filter" the pull request ID to detect repository name.

The pull request ID as shown by JIRA seems to be a link that has some text and associated URL, e.g.

Text: parent/child!3  : This would be pull request #3 within parent/child repository

URL: https://gitlab.com/parent/child/-/merge_requests/3  : GitLab calls it Merge Request

I would like to detect "parent/child" within the pull request ID and do things differently depending on the actual repository names.

I would appreciate any pointers that can help me implement such rule.

Thanx,

Bogdan

1 answer

1 accepted

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2021

Hi @Bogdan Kosanovic  -- Welcome to the Atlassian Community!

Are you using the Pull Request Merged trigger in your rule?  If so, have you checked this value to see if it has the repo information you need:

{{pullRequest.destinationBranch.repository}}


Best regards,

Bill

Bogdan Kosanovic March 29, 2021

Hello @Bill Sheboy

Thanks for the hint. That is exactly what I was looking for. I'll try it out and report back. I even tried to "guess" the variable name to check. :)

BTW, where can I find the list of all such classes/objects that can be used in conditional rules?

Best Regards,
Bogdan

Bogdan Kosanovic March 29, 2021

Actually, I found the place where all those smart values are listed. (https://support.atlassian.com/jira-software-cloud/docs/smart-values-development/)

The first attempt did not work, but I'll try a bit more before I ask another question.

Regards,
Bogdan

Like Bill Sheboy likes this
Bogdan Kosanovic March 29, 2021

Ok. So, I figured this out (at least for my case). I had to use

{{pullRequest.destinationBranch.repository.url}}

Without the URL I could not use "does not contain" or "contains" successfully within the if-block condition. Maybe it is the way GitLab reports the repository. Nevertheless, it worked.

Thanks @Bill Sheboy for your help!

Regards,
Bogdan

Like Bill Sheboy likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2021

I am glad to hear that helped.  Consider keeping a watch on that development smart value page and this issue to see other improvements in automation:

https://codebarrel.atlassian.net/browse/AUT-1997

Like Bogdan Kosanovic likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events