Bitbucket Pipeline Mail can not attach more than one file
Asked by pascal_schroeer:

I just wanted to extend my Bitbucket pipeline to send more than one attachment via Mail. For this I use the following .yml file:

```
image: dme26/latex-builder:latest

pipelines:

default:

 - step:

name: Build the .pdf

script:

 - cd LaTeX

 - pdflatex Installation-Plan.tex

 - pdflatex Installation-Plan.tex

artifacts:

 - LaTeX/Installation-Plan.pdf

 - Data/data.csv

 - step:

name: Upload to Bitbucket Downloads

script:

 - pipe: atlassian/bitbucket-upload-file:0.7.1

variables:

BITBUCKET_USERNAME: '$BITBUCKET_USERNAME'

BITBUCKET_APP_PASSWORD: '$BITBUCKET_APP_PASSWORD'

FILENAME: 'LaTeX/Installation-Plan.pdf'

 - pipe: atlassian/bitbucket-upload-file:0.7.1

variables:

BITBUCKET_USERNAME: '$BITBUCKET_USERNAME'

BITBUCKET_APP_PASSWORD: '$BITBUCKET_APP_PASSWORD'

FILENAME: 'Data/data.csv'

 - step:

name: Send email

script:

 - MY_DATE=${MY_DATE:-$(date +%Y-%m-%d)} 

 - pipe: atlassian/email-notify:0.13.1

variables:

USERNAME: '$GMAIL_MAIL'

PASSWORD: '$GMAIL_APP_PASSWORD'

FROM: smtp.my@gmail.com

TO: 'myMail@icloud.com, mySecondMail@web.de'

HOST: 'smtp.gmail.com'

PORT: 587

SUBJECT: '$MY_DATE Installation-Plan'

ATTACHMENTS: 'LaTeX/Installation-Plan.pdf,Data/data.csv'
```

Everything works fine and also the pipeline tells me that everything is fine. But the mail I receive only includes one of the shown attachment! In this case I just receive the "data.csv" file. When I just remove ",Data/data.csv" I receive a mail with the Installation-Plan.pdf.  
I followed exactly the docs...  
<https://bitbucket.org/atlassian/email-notify/src/master/>  

```
script:  - pipe: atlassian/email-notify:0.13.1    variables:      USERNAME: 'myemail@example.com'      PASSWORD: $PASSWORD      FROM: 'myemail@example.com'      TO: 'example@example.com'      HOST: 'smtp.gmail.com'      ATTACHMENTS: 'file1.txt,file2.txt'
```

What's wrong here?


Answers:
author: pascal_schroeer
body: In my in inbox I see this:

![IMG_3318.jpeg](https://community.atlassian.com/t5/image/serverpage/image-id/308880i1FCA4346088ED3C7/image-size/large?v=v2&px=999 "IMG_3318.jpeg")

So two attachments are mentioned, but only the file ?data.csv" is attached.

comments: author: Igor Stoyanov
body: [@pascal_schroeer](/t5/user/viewprofilepage/user-id/3684564) hi. I used this pipe by myself and see the two files.![Screenshot 2024-03-01 at 17.41.41.png](https://community.atlassian.com/t5/image/serverpage/image-id/309717i1A72C83ED7E677BD/image-size/large?v=v2&px=999 "Screenshot 2024-03-01 at 17.41.41.png")  
Regards, Igor


author: pascal_schroeer
body: Hmm for me it is not working. I tried also different mail addresses, but still the same issue...


author: Igor Stoyanov
body: [@pascal_schroeer](/t5/user/viewprofilepage/user-id/3684564) . Maybe you have problems with the second file. Try to attach only problem file to exclude this reason.  

Regards, Igor


author: pascal_schroeer
body: [@Igor Stoyanov](/t5/user/viewprofilepage/user-id/4550492) Alteady done... I switched the two files in the attachment statement. This results in sending me the other file... this is why I thought it must be a syntax error...

Can you maybe give me a minimal working example for zip'ping these files before sending? At least then it should be fixed.


author: Igor Stoyanov
body: [@pascal_schroeer](/t5/user/viewprofilepage/user-id/3684564) i do not know what is inside you image exactly, so some general idea:  
Inside this step

```
 - step:

name: Build the .pdf

script:
```

```
 <install zip if not present i.e apt-get install zip.
 Depends on your image>

 - cd LaTeX

 - pdflatex Installation-Plan.tex

 - pdflatex Installation-Plan.tex
 < seems like here you created a files.
 So zip them: zip <options> <zip file> <source file>>
 artifacts:
 - <your zip files>

```

And then use zipped files with the pipes below.  
More [details how to zip](https://phoenixnap.com/kb/how-to-zip-a-file-in-linux).  

Regards, Igor


author: pascal_schroeer
body: Okay this works now... :)

BR


Tags: bitbucket-cloud

bitbucket-pipelines

cloud