How to get logs of codepipeline using aws cli?
Asked Answered
S

1

7

So when I trigger a codepipeline using the below command:

aws codepipeline start-pipeline-execution --name MyFirstPipeline

I only get an asynchronous response

{
    "pipelineExecutionId": "c53dbd42-This-Is-An-Example"
}

Now how do I stream the logs of build and deploy stages?

P.S I can see the logs in cloud watch but how can I get that logs using AWS cli?

Screens answered 29/4, 2021 at 19:10 Comment(6)
Which logs? Do you have any example/screenshot?Empoison
I mean codedeploy and codebuild logs via AWS cliScreens
They will be in cloudwatch.Empoison
yeah but I am triggering using CLI. How Can I see that logs in terminal using AWS CLI?Screens
You can't. You have to query CloudWatch independently.Empoison
You can access codebuild and codedeploy logs from CLI using aws logs command. An example to get codebuild logs is to first get the log group aws logs describe-log-groups --query 'logGroups[?contains(logGroupName, codebuild)]', then get the log-streams using aws logs describe-log-streams --log-group-name --log-stream-name and finally you call aws logs get-log-events with the log-group-name and log-stream-name that you got from previous 2 commandsGenipap
P
0

AFAIK we can integrate codepipeline to store logs in cloudwatch. You can use aws cli to get logs from cloudwatch using below approaches

  • aws logs get-log-events --log-group-name <LOG_GROUP_NAME> --log-stream-name <LOG_STREAM_NAME>

If you want fancy stuff you can also look into https://github.com/jorgebastida/awslogs to get logs

Pyrostat answered 9/9 at 17:40 Comment(1)
But the question was how to make the link from CodePipeline ... could you elaborate?Sst

© 2022 - 2024 — McMap. All rights reserved.