7

How can I set an email to be sent upon completion or failure of a job in Concourse?

prismaticorb
  • 865
  • 1
  • 7
  • 18

2 Answers2

2

You can use https://github.com/pivotal-cf/email-resource along with the on_failure step: https://concourse-ci.org/on-failure-step.html

Dwayne Forde
  • 1,206
  • 13
  • 13
Benedict Dodd
  • 245
  • 2
  • 8
  • Can this be expanded upon? How do you use a "put" resource within the on failure task? Example please? – Austin L Jan 06 '20 at 20:42
0

I think this may be already answered but if it helps it will look something this:

jobs:
- name: myBuild 
  plan:      
  - get: your-repo
    passed: []
    trigger: false
  - task: run-tests
    file: runMyTestsTask.yml   
  on_failure:
  - put: send-an-email
    params:
      subject_text: "Your email subect i.e Failed Build"
      body_text: "Your message when the build has failed"
  on_success:
    put: push-my-build

## Define your additional resources here

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" ] #optional if `params.additional_recipient` is specified

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

Checkout the documentation for more details on the email resource https://github.com/pivotal-cf/email-resource

Peter Arboleda
  • 195
  • 1
  • 10