We've been using AWS CodeBuild to run java maven builds almost since it came out. It's great when it works, but when Maven has a problem it can pretty pretty difficult to sift through logs in the Cloudwatch console.
Below is an AWS Powershell Tools snippet that will pull down a cloudwatch log stream and dump it both to your console and to a file. There are a few parameters you'll need to set
Below is an AWS Powershell Tools snippet that will pull down a cloudwatch log stream and dump it both to your console and to a file. There are a few parameters you'll need to set
- LogStreamName - this should be the specific log stream you want to download. Usually this correlates to a Codebuild run
- LogGroupName - this will be the /aws/codebuild/<your project name>
- OutFile location - this is where you want the files dumped
Get-CWLLogEvents -logstreamname logstreamname -loggroupname /aws/codebuild/yourprojectname).events | foreach {$message = "$($_.TimeStamp) - $($_.Message)";write-host $message; $message | out-file logfilelocation.log -append}
This command can also be used to pull down other log streams as well, you just need to swap out the same variables.
Happy troubleshooting!
No comments:
Post a Comment