Using trigger "When: Pull request created" how can you run the rule only once for multiple issues

Marc-André March 19, 2021

In Jira Automation when using the When: Pull request created I typically have an Issue fields condition step that checks for a Component field value and then post a message to Microsoft Teams.

The issue I'm facing is that if the pull request in question contains more than one issue it will post multiple messages to teams, one for each issue in the pull request.

Is there a way of validating the component of either all or the first issue in the pull request and proceed to only post a single message to Microsoft Teams.

 

Thanks!

2 answers

1 accepted

0 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.
April 8, 2021

Hi @Marc-André 

Full disclosure: I am not actively using the DevOps triggers at this time, and based on what I understand about them, I wonder if you could...

  • When the pull request trigger fires the rule, it has the {{pullRequest.title}}
  • As you note the title contains multiple issues, you could parse those issue keys out using the text functions and RegEx
  • Then pick one of them (e.g. first) to get the sampled key
  • Use an Advanced Compare Condition to prevent a loop, only proceeding if the trigger Issue key matches the sampled key
  • Log your message to Microsoft team

 

Best regards,

Bill

Marc-André April 13, 2021

Hi @Bill Sheboy

Thank you for your answer. Although a bit more complex than I expected this automation to be this does solve my issue.

We might miss some PRs or get invalid notifications if a user does not name the PR appropriately but in the end this greatly eliminate notification spam.

Lets hope the values contained in the pullRequest payload gets expanded a bit in the future.

 

Best regards,

Mark

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.
April 13, 2021

Mark, you may also want to search in the Code Barrel (now part of Atlassian) backlog to see when they might improve this area in triggers.  Unfortunately we cannot vote for/watch issues in this backlog.

https://codebarrel.atlassian.net/issues/?jql=project %3D AUT AND resolution %3D Unresolved ORDER BY Key DESC&startIndex=50

Best regards,

Bill

0 votes
Marc-André April 8, 2021

Good to know.

Suggest an answer

Log in or Sign up to answer