3
votes

I am trying to add some notifications to my Pipeline in AWS. I have a build stage where I use AWS CodeBuild and I want to receive an email whenever the build fails.

I have followed the tutorial that amazon offers and it works fine to notify me about the failure, but I can't seem to find how to add the logs in the email.

I have created the following CloudWatch Event Rule, which monitors the execution of the entire Pipeline.

{
  "source": [
  "aws.codepipeline"
  ],
  "detail-type": [
    "CodePipeline Pipeline Execution State Change"
  ],
  "detail": {
    "state": [
      "FAILED",
      "SUCCEEDED",
      "CANCELED"
    ],
    "pipeline": [
      "Pipeline_Trial"
    ]
  }
}

Can anyone help me figure how to add the logs to this rule ?

1
By logs do you mean eg. the CodeBuild build logs? - TimB
Exactly , @TimB - Yuri Azar

1 Answers

4
votes

The event from CodePipeline does not contain the CodeBuild logs so you can't pass this through to your email without something in the middle.

A solution could be to have your CloudWatch event target a Lambda function which looks up the logs via the CodeBuild / CloudWatch logs API. It can then generate the email including the logs and send the notification via SNS.