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

Jira Automation sent duplicated messages to Slack

Davyd Derkach July 23, 2024

Hello, everybody!

I have created following automation that sends message containing Jira Issue keys and Issue summary to Slack:

image_2024-07-23_192854414.png

1. As a trigger I have incoming webhook with a list of Jira Issue Keys.
2. Then I create a variable from {{webhookData.issues}}

3. After that there is lookup over {{webhookData.issues}}

4. Then sending following message to slack:

Time: {{webhookData.timestamp}}

Issues included in this release:

{{#lookupIssues}}

* {{key}} {{summary}}

{{/}}

5. 
After that some transition of the issues.

Here example of what my API call looks like:

curl -X POST -H 'Content-type: application/json' --data '{"issues":["BDO-391","BDO-392"], "data": {"issues":["BDO-391","BDO-392"], "timestamp":"13:30"}}' https://automation.atlassian.com/pro/hooks/<my-webhook>

Here a duplicated messages in Slack for each Jira Issue:

test-1.png

Thanks in advance for your help!

1 answer

1 accepted

1 vote
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.
July 23, 2024

Hi @Davyd Derkach -- Welcome to the Atlassian Community!

The rule's trigger is using the option "Issues provided in the webhook HTTP POST body", and so the steps loop over each issue provided.

You could change your rule to instead use the option "No issues from the webhook" and pass only the issue keys in the custom data.  Then you could control how the rule handles them.

For example, the data from the sending application could be passed as:

{ "data": { "keys": "BDO-392,BDO-391" } }

And then the JQL to access the issues in your rule would be:

 key IN ( {{webhookData.keys}} ) 

Kind regards,
Bill

Davyd Derkach July 23, 2024

Hello, Bill!
Thanks a lot for quick response.

Your suggestion of using  key IN ( {{webhookData.keys}} ) helped to not receive couple messages in Slack. For now I receive only one as expected.

However the branch part, in which I check for issue status and then perform a transition is not working with this setup:

test-1.png


In Rule "Issue fields condition" the warning appeared with following details:

test-2.png

In "Advanced branching" i use smart value {{webhookData.keys}} in for each (visible on first screenshot).

The API call that I sent:

curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' https://automation.atlassian.com/pro/hooks/<my-webhook>

----
Thanks in advance and sorry for my sometimes lazy questions since it`s my first task related to Jira automation(


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.
July 23, 2024

You could replace the advanced branch with a branch on JQL with the same JQL I provided for the Lookup Issues action.  That will enable iterating over the issues.

Davyd Derkach July 23, 2024

Thank again @Bill Sheboy
It`s helped me to receive only one message in Slack and to transition issues correctly.

Here is final look of my automation for others, who may face same issues:

image_2024-07-23_234445965.png

The API call that I execute, looks like this:

curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' https://automation.atlassian.com/pro/hooks/<your-webhook>

Like Bill Sheboy likes this
Davyd Derkach August 14, 2024

Hello again, @Bill Sheboy
I have one more question and maybe you can help me with it?

Currently after each pipeline run I a script which use a webhook API call to sent Jira Issue keys that related to current release to my Jira Automation:

curl -X POST -H 'Content-type: application/json' --data '{"data": {"keys": "BDO-392,BDO-391"}}' https://automation.atlassian.com/pro/hooks/<your-webhook>

Also, I need to sent another information like release tag version, release date etc. and later this will be sent to Slack with my Jira Automation above.

So I am wondering is there a way not to use script with API call to sent Jira Issue keys and another information? I saw in documentation something about smart values like:  https://support.atlassian.com/cloud-automation/docs/jira-smart-values-development/

But I cant find information whether these smart values will be available in case I am not send them via Webhook URL but just reference them into automation. I have GitLab integration with my Jira.

Also maybe you know smart values that can help me to retrieve Jira issue keys that related to current release tag, Release Engineer name, date of pipeline run and Jira issue summary?

Thanks in advance!

 

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.
August 14, 2024

In general, most of the automation smart values apply when an issue is available to the rule.

For an incoming webhook from Jira itself, it is possible to send the issue content.  But your source for the webhook is different.

Using some of the data you reference, you would likely need to use your source control / release management tool to find the relevant issues' keys and then look them up with JQL once inside the automation rule.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events