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

Sending mail from docker image in pipeline

Jani Ruohomaa March 5, 2021

Hi,

I am pulling down my own docker image from docker hub in bitbucket pipelines and would like to send mail from within the docker image

I am using mail command and everything works fine when running the docker image on my own computer. I am using gmail as the mail provider.

but when I do the same in pipeline it does not work. I don't get any error message or anything so that I would see what is actually wrong

I tried to put the debug logs on on the mail command but I don't get any output in pipeline

on my local laptop (wls2 on windows), I get some debug log output and like said before it works fine

Any ideas what's wrong ?

-Jani

1 answer

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2021

Hi @Jani Ruohomaa

Thank you for your question!

It's a great case for the custom pipe. We have cool and simple guides How to create a custom pipe as part of 12 days of CI/CD series.

Usage example for your custom pipe could be the next:

pipelines:
default:
- step:
script:
- pipe: docker://your-repository/your-custom_email-image:latest
variables:
USERNAME: $USERNAME
PASSWORD: $PASSWORD


Cheers,
Oleksandr Kyrdan

Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2021

Also, we have open-sourced email-notify pipe,
so you could see how it build or use it just adding the next configuration to your pipeline:

scripts:
  - pipe: atlassian/email-notify:0.4.3
    variables:
      USERNAME: 'myemail@example.com'
      PASSWORD: $PASSWORD
      FROM: 'myemail@example.com'
      TO: 'example@example.com'
      HOST: 'smtp.gmail.com'

Cheers,
Oleksandr Kyrdan

Like Steffen Opel _Utoolity_ likes this
Jani Ruohomaa March 6, 2021

Thanks for the info, I have tried that email-notify pipe and it works fine but the problem I have is that I am running pmd and I want to send the result in the email body

I couldn't figure out how to expose the result to the email-notify so I decided to do the email sending from within the docker image also

Do you have any idea why the email sending does not work ? It works find if I log into the image and run the analysis and then send the result from my own laptop. In this case the host where the image is run is of course is different than in the pipeline

Jani Ruohomaa April 13, 2021

Does anyone have any luck sending mail from within a docker image ? I am running within the docker image pmd analysis, generating a html file and then sending the result with mail.

This all works fine on my own laptop but not in pipeline. The pmd analysis runs fine but not the mail sending. There are no errors. I tried putting on the debug levels for the mail command but it does not debug anything. When I run the mail command on my laptop within the docker image I get the debug statements.

It seems issuing that mail command within the docker image does not work at all, anyone have any experience with the same ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events