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

How to attach report to email notification after failing manual or scheduled pipeline run?

Marek Zielonkowski June 3, 2020

We are using pipelines to run E2E tests. When it fails, bitbucket sends email notification. We would like to receive a zipped file attached to this email. E2E tools generate reports, we would like to get these reports to see what went wrong. How to achieve this?

2 answers

0 votes
Maria Bobrova January 6, 2022

@Oleksandr Kyrdan  hi! Could you help me please?

I have done everything as you write above, but somehow when Pipeline try to find an attachment - it shows an error. 

noSuchFile.jpg   

Here is my ymlFile, can you please tell me - what I have write wrong so attachment doesn't loads.

ymlFile.jpg  Thank you! And Happy New Year! And Merry Christmas!)

UPDATE

Have added full path to the file and it looks like it works. However the email is not send anyway sendingEmail.jpg

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2020

Hi @Marek Zielonkowski ,

Thank you for your question!

It's a good case to use the email-notify pipe.

You can use $BITBUCKET_EXIT_CODE variable in the after-script section.
$BITBUCKET_EXIT_CODE - the exit code of a step, if step success value setup to 0.

script:
- <your test logic>
- pytest test/test.py --junitxml=test-reports/report.xml
- zip -r test-reports.zip test-reports
after-script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.3.11
variables:
USERNAME: 'myemail@example.com'
PASSWORD: $PASSWORD
FROM: 'myemail@example.com'
TO: 'example@example.com'
HOST: 'smtp.gmail.com'
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'
ATTACHMENTS: 'test-reports.zip'
brixomatic October 11, 2020


That will fail with:


✖ Validation errors:
SUBJECT:- must be of string type

Christian Koschmieder de Juan January 4, 2023
SUBJECT: "'${ALERT_TYPE}:Notification-TG Files Adapted Properly for ${BITBUCKET_BRANCH}'"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events