mdomke / concourse-email-resource

A simple email resource for concourse CI
MIT License
3 stars 13 forks source link

Email Resource

A Concourse CI resource to send emails.

Source Configuration

Example

Adding the resource to your project:

resource_types:
- name: email
  type: docker-image
  source:
    repository: mdomke/concourse-email-resource

Resource configuration:

resources:
- name: send-email
  type: email
  source:
    from: ci@example.com
    host: smtp.example.com

Sending an email message:

- put: send-email
  params:
    to: [recipient@example.com]
    subject: subject.txt
    body: body.txt

Behavior

check and in operations are a noop.

out: Send an email message

Parameters

subject|subject_text and body|body_text can both either be plain text, html or a jinja-template. In the latter case you can specify an additional file (vars) for holding template variables that should be rendered into the template. Additionally to the variables from the vars-file, all environment variables can be used in the template (e.g.: BUILD_ID). By default (if the MIME subtype is "html"), the CSS styles will be inlined to the HTML. If you don't want that, you can set the inline_css parameter to False. If you want to use jinja-template in subject_text or body_text you need to define the content as a multiline text, otherwise a syntax error will be reported for malformed yaml.

- put: send-email
  params:
    to: [recipient@example.com]
    subject_text: |
      {% block BUILD_PIPELINE_NAME %}{% endblock %}:{% block BUILD_JOB_NAME %}{% endblock %} failed
    body_text: |
      {% block BUILD_PIPELINE_NAME %}{% endblock %}:{% block BUILD_JOB_NAME %}{% endblock %} failed

A more elaborate usage example would look like this:

- put: send-email
  params:
    to: [recipient@example.com]
    subject: subject
    body: body.html
    vars: vars.json

or for a plain text example:

- put: send-email
  params:
    to: [recipient@example.com]
    subject: subject.txt
    body: body.txt
    type: plain