A Concourse resource that sends emails.
Add the following Resource Type to your Concourse pipeline
resource_types:
- name: email
type: docker-image
source:
repository: pcfseceng/email-resource
Look at the demo pipeline for a complete example.
This resource acts as an SMTP client, using PLAIN
auth over TLS. So you need an SMTP server that supports all that.
For development, we've been using Amazon SES with its SMTP support
An example source configuration is below. None of the parameters are optional.
resources:
- name: send-an-email
type: email
source:
smtp:
host: smtp.example.com
port: "587" # this must be a string
username: a-user
password: my-password
from: [email protected]
to: [ "[email protected]", "[email protected]" ]
An example source configuration is below supporting sending email when anonymous is permitted.
resources:
- name: send-an-email
type: email
source:
smtp:
host: smtp.example.com
port: "587" # this must be a string
anonymous: true
from: [email protected]
to: [ "[email protected]", "[email protected]" ]
Note that to
is an array, and that port
is a string.
If you're using fly configure
with the --load-vars-from
(-l
) substitutions, every {{ variable }}
automatically gets converted to a string.
But for literals you need to surround it with quotes.
This is an output-only resource, so check
and in
actions are no-ops.
headers
: Optional. Path to plain text file containing additional mail headerssubject
: Required. Path to plain text file containing the subjectbody
: Required. Path to file containing the email body.send_empty_body
: Optional. If true, send the email even if the body is empty (defaults tofalse
).istemplatesubject
Optional. If true, subject file is assumed to contain concourse env variables to be replaced (defaults tofalse
).istemplatebody
Optional. If true, body file assumed to contain concourse en variables to be replaced (defaults tofalse
).
A build plan might contain this:
- put: send-an-email
params:
subject: demo-prep-sha-email/generated-subject
body: demo-prep-sha-email/generated-body
If using template files, the generated subject and body files should contain place holders to be replaced with Concourse
build metadata. For eg, a generated template file with Concourse metadata place holders would look something like this :
echo "Build {{.BuildJobName }} of {{.BuildPipelineName}} pipeline failed" >> ./emailout/email-subject-failure.txt
echo "Build {{.BuildName }} of job {{.BuildJobName }} for pipeline {{.BuildPipelineName}} failed." >> ./emailout/email-body-failure.txt
echo "Please see the build details here : {{.ExternalURL }}/teams/{{.BuildTeamName}}/pipelines/{{.BuildPipelineName}}/jobs/{{.BuildJobName}}/builds/{{.BuildName}}" >> ./emailout/email-body-failure.txt
To send HTML email set the headers
parameter to a file containing the following:
MIME-version: 1.0
Content-Type: text/html; charset="UTF-8"
Get yourself familiarized with Godep
[https://github.com/tools/godep]. Download it and then add it your path. Then run
godep go build -o bin/check ./actions/check
godep go build -o bin/in ./actions/in
godep go build -o bin/out ./actions/out
cd tests
godep go test