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

how can I pass dynamically file name for Attachment under my pipe?

Depstan Thankachan Xavier March 8, 2023
- pipe: atlassian/email-notify:0.8.0
variables:
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}: Build ${BITBUCKET_BUILD_NUMBER}'
ATTACHMENTS: test-results/ *.html
Currently this is throwing me error saying *.html file not found to attach. The result file is generated as testResult_yyyy_MM_DD_HH_MM_SS.html format. where the bold letters are dynamic values.

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 9, 2023

Hello @Depstan Thankachan Xavier ,

Thank you for reaching out to Atlassian Community!

The ATTACHMENTS attribute in the pipe expects a fixed file name, and it will not expand the filenames to match a pattern like *.html.

In this case, I would suggest compressing the files in a .zip - where this compressed file would have a fixed name - and then adding the zip file as the attachment.

Following is an example of using the zip command to compress all the *.html files within the test-results folder in a zip file named my_html_files.zip :

- zip my_html_files.zip test-results/*.html

If the zip command is not available  (command not found) in the docker image you are using, you will need to install it using the following command :

- apt-get update && apt-get install -y zip

Then, in the pipe's ATTACHMENTS attribute, you can specify the name of the compressed file which will be a fixed name. The complete YAML step would look like below : 

- apt-get update && apt-get install -y zip  #only necessary if the image does not have zip 
- zip my_html_files.zip test-results/*.html
pipeatlassian/email-notify:0.8.0
variables:
SUBJECT'${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}Build ${BITBUCKET_BUILD_NUMBER}'
ATTACHMENTS: "my_html_files.zip"

Hope that helps! Let me know in case you have any questions.

Thank you, @Depstan Thankachan Xavier !

Patrik S

Depstan Thankachan Xavier March 28, 2023

this helps thanks @Patri 

Suggest an answer

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

Atlassian Community Events