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

How to write e-mail notification after LaTex build

pascal_schroeer December 22, 2020

I want to automatically build a LaTex document (step 1) and after that send the generated .pdf file via e-mail as attachment (step 2).

STEP 1: (WORKS)

image: dme26/latex-builder:latest
pipelines:
branches:
master:
-
step:
script:
-
pdflatex
-jobname=Test Test.tex;
- pdflatex -jobname=Test Test; - ls - curl -X POST "https://${BB_AUTH_STRING}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"Test"

 STEP 2: (ERROR)

- step: 
script:
-
pipe: atlassian/email-notify:0.4.2
variables:
USERNAME: $EMAIL_ADDRESS
PASSWORD: $EMAIL_PW
FROM: $EMAIL_ADDRESS
TO: $ANOTHER_EMAIL_ADDRESS
HOST: 'smtp.googlemail.com'
#ATTACHMENTS: 'Test.pdf' #SEND generated .pdf

1 answer

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

Hi @pascal_schroeer ,

thank you for your question!

In your case, artifacts will help you to share generated pdf-file with the next steps:

image: dme26/latex-builder:latest
pipelines:
default:
- step:
name: Build the pdf
script:
- pdflatex --shell-escape Test.tex
artifacts:
- Test.pdf
- step:
name: Upload to Bitbucket Downloads
script:
- pipe: atlassian/bitbucket-upload-file:0.3.2
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
FILENAME: 'Test.pdf'
- step:
name: Send email
script:
- pipe: atlassian/email-notify:0.4.2
variables:
USERNAME: $EMAIL_ADDRESS
PASSWORD: $EMAIL_PW
FROM: $EMAIL_ADDRESS
TO: $ANOTHER_EMAIL_ADDRESS
HOST: 'smtp.googlemail.com'
ATTACHMENTS: 'Test.pdf'

Also, it's a best practice to separate build and upload/send steps.

Cheers,
Oleksandr

pascal_schroeer December 23, 2020

test

pascal_schroeer December 23, 2020

Hello 

Thanks for your explanation! I changed my pipeline code to your suggestion.

But there are still two open points.

  1. pdflatex has to be called twice, but you called it only once. How can I achieve this in the best way?
  2. The email sending is not working. I get the following error message: Failed to send email to $BITBUCKET_USERNAME@icloud.com. Check your configuration settings.
    Are all my email settings correct?

Best Regards!

Pascal

pascal_schroeer February 25, 2024

@Oleksandr Kyrdan Can you please have a look at this question? https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Pipeline-Mail-can-not-attach-more-than-one-file/qaq-p/2620066

I'm not able to send more than one attachment in the same mail...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events