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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,677
Community Members
 
Community Events
176
Community Groups

How do I add attachments to an e-mail with Automation for JIRA

andreas Rising Star Mar 06, 2017

Is it possible to add attachments to an e-mail with Automation for JIRA ?

7 answers

1 accepted

6 votes
Answer accepted

So you can't embed attachments directly in an e-mail (we don't support this due to the fact that attachments in JIRA could be far to large for emails), but you can add links using smart fields.

Here's an example rule:

Project automation - Code Barrel JIRA 2017-03-07 11-12-49.png

So this email body will iterate over all attachments on an issue and produce links that allow recipients to download the attachment directly from JIRA: 

Hi there,


Attachments:
<ul>
{{#issue.attachment}}
<li><a href="{{content}}">{{filename}}</a></li>
{{/issue.attachment}}
</ul>

Cheers,
  Auto

Hello @andreas - can this code be adapted to add a comment (instead of an email) with links to all attachments?  Thanks!

Like # people like this

Hi @andreas. We want to send the attachments to an external support user, but the link would require a JSD account. Is there any way around this now? Thanks.

Like # people like this

Hi @andreas , really Automation for Jira has been great to work with. We are slowly learning how to optimize our JIRA instance. In light of this question, I am having trouble adding the attachment link to an email. The caveat is that Im using another plugin for creating additional attachment custom fields. 

Would you have a suggestion for how to deliver the link to the attachment in our custom field (customfield_17703). The reporter role would be the recipient of the email.

Any help would be greatly appreciated. 

Cheers

Is there a way to do that with the Triggered Issue? I tried with this codes without luck any suggestions?


{{#triggerIssue.attachment}}
* [{{filename}}|{{content}}]
{{/}}


{{#triggerIssue.fields.attachment}}
* [{{filename}}|{{content}}]
{{/triggerIssue.fields.attachment}}

So far I could not find a way to overcome the limitations to send the attachments to the external support user purely using Jira tools. Even exposing them to the portal is a bit tricky, they need to be inside a comment.

I ended up fashioning a PHP script to expose a REST endpoint that would ingest destination email list, the email body and the attachment details then compose and send such emails from the corporate email servers. In automation instead sending the email I am sending a request to that endpoint. 

The PHP script itself logs in to Jira instance with an admin token hence it has access to all attachments it needs.

Like Javier_Corchado likes this

The alternative is to use an app like Notification Assistant for Jira which supports sending attachments up to 20 MB in size.

Hi @andreas 

Is there any possibility to attach a particular attachment only in the email notification. Can you please confirm me once.

@andreas / All  - Now that JIRA is allowing to download Email attachments directly from email notifications rather than logging into the portal, can you please hep advise how we can acheive the same via Automation - Send Email option please?

Reay appreciate all your support in this regard.

Regards,

Krishna

I still cannot work around that the link in question that is created from the smart values does not allow anyone other than admins to see the file. Is there a way we can open this to any customer or user in the tenant?

Hi, 

{{#issue.attachment}}<li><a href="{{content}}">{{filename}}</a></li>{{/issue.attachment}}

This code displays a list of all attachments, how to get only the file that is added now? for example, by the trigger for changing the attachment field - display a comment only with the attachment added.

{{#issue.attachment.last}}<li><a href="{{content}}">{{filename}}</a></li>{{/issue.attachment.last}}

Would this only pull down the only most recent file?

Yes, it returns the most recent array element.

David, when I use the .last it pulls the last attachment in the list rather than the most recently added to the list.  

Is there a way to get last by date?

Tnx
-Matt

Like Javier_Corchado likes this

Hi Matthew, when I used this, the attachments list (array) was populated internally chronologically, meaning the last one also was the most recent one. In case Atlassian has changed something there, you could also try '.first' instead of '.last'.

There is an ugly third possibility: If (like in the 'Approvers' array field) the order (index) of the attachments array elements keeps constantly changing, you would have to (only very quick summary) use the new automation feature (formerly Automation for Jira) to create a rule that

  • gets the total number of attachments (attachment.size)
  • iterates in a loop over each object id (attachment.get(0 to [whatever is attachment.size.minus(1)]) by creating fields in your issue that can be used as loop variables for
    • loop iteration
    • and array object index (this is tricky, because '.get(X)' requires a 'real' integer, and Jira number field data type is always floating point, so you'd need to e.g. use an auxiliary label field to be populated loop iteration by iteration with one additional element, then the 'auxiliary.size' property will return you a 'real' integer you can leverage for use in .get(x))
  • pull the 'attachment.get(x).created' properties for each element in attachments
  • save this somewhere together with the array index for a date comparison to decide what's newest (or in each loop iteration discard the previous iterated element when the current one is newer).

Hope that helps! 

Like Javier_Corchado likes this

For anyone else who comes across this... I had trouble with the code above, but this seemed to work for me: 

Attachments:
<a href="https://example.com/jira/secure/attachment/{{issue.fields.attachment.id}}/{{issue.fields.attachment.filename}}">{{issue.fields.attachment.filename}}</a>

Hi, @Susan Ostreicher only administrator of Jira can access this link, so what about other users?

Like Jude Botten likes this

Hi, 

Use the lagacy automation. With the legacy automation you can also send the ticket description. In case the ticket description contains images etc, they are sent. 

Best regards

Stephan 

Hi Stephan,

what about comments with attachements?

Like Shane Johnson likes this
0 votes

Hi @AKSHAY THAKARE, I'm sorry for the slow reply. From what I can tell, anyone with permission to view the request (e.g. a reporter or a request participant) can access that link. Have you seen that's not the case? 

Yeah, but in my case, this is not happening only admin can access that link even reporter also not able to view that attachment.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events