AWS Code Commit Slack Integration - How to display author and commit message

Viewed 700
2 Answers

Unfortunately the GitPush event only contains the commit id and the branch name:

  "eventName": "GitPush",
  "awsRegion": "us-east-1",
  "sourceIPAddress": "52.21.1.64",
  "userAgent": "git/2.20.1 (Apple Git-117)",
  "requestParameters": {
    "references": [
      {
        "commit": "758822355756e0badd633debe441792",
        "ref": "refs/heads/master"
      }
    ]
  },

Probably one way is to invoke a Lambda on GitPush CloudWatch event, then do some further interrogation in the Lambda to find out the author of the commit:

$ git log --format=%B -n 1 <commit>

I have created a Lambda function to make that thing work. I have post my answer here. I hope it helps.

https://stackoverflow.com/a/73537593/1682525

After lambda function integration and added trigger to codecommit. I could see commit details in Slack channel feed. You can customized the feed response too. The code in Lambda is preety straight forward.

enter image description here

I hope it helpe someone.

Related