Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodePipeline Notifications

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 ?

like image 391
Yuri Azar Avatar asked Nov 23 '25 21:11

Yuri Azar


1 Answers

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.

like image 74
TimB Avatar answered Nov 27 '25 14:11

TimB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!