Skip to content

A Concourse resource that sends emails. This version of the email-resource allows template based subject and body files

License

Notifications You must be signed in to change notification settings

anwarchk/email-resource

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Resource

A Concourse resource that sends emails.

Getting started

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

Source Configuration

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: build-system@example.com
    to: [ "dev-team@example.com", "product@example.net" ]

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: build-system@example.com
    to: [ "dev-team@example.com", "product@example.net" ]

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.

Behavior

This is an output-only resource, so check and in actions are no-ops.

out: Send an email

Parameters

  • headers: Optional. Path to plain text file containing additional mail headers
  • subject: Required. Path to plain text file containing the subject
  • body: Required. Path to file containing the email body.
  • send_empty_body: Optional. If true, send the email even if the body is empty (defaults to false).
  • istemplatesubject Optional. If true, subject file is assumed to contain concourse env variables to be replaced (defaults to false).
  • istemplatebody Optional. If true, body file assumed to contain concourse en variables to be replaced (defaults to false).

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

HTML Email

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"

Build from the source

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

To run the tests

cd tests

godep go test

About

A Concourse resource that sends emails. This version of the email-resource allows template based subject and body files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.5%
  • Shell 3.5%