File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,14 @@ def readXML_and_publish_metrics_to_cw():
1313 failures = testsuite .attrib ["failures" ]
1414 tests = testsuite .attrib ["tests" ]
1515 successes = int (tests ) - int (failures )
16+ success_rate = (successes / int (tests ))* 100
1617 else :
1718 print ("f{xml_path} does not exists." )
1819 print (os .getcwd ())
1920 failures = 0
2021 successes = 0
21- tests = 23
22+ tests = 0
23+ success_rate = 0
2224
2325 timestamp = datetime .now ().strftime ("%Y-%m-%dT%H:%M:%S" )
2426
@@ -59,6 +61,15 @@ def readXML_and_publish_metrics_to_cw():
5961 "Value" : int (successes ),
6062 "Unit" : "Count" ,
6163 },
64+ {
65+ "MetricName" : "success_rate" ,
66+ "Timestamp" : timestamp ,
67+ "Dimensions" : [
68+ {"Name" : "CodeBuild Project Name" , "Value" : project_name },
69+ ],
70+ "Value" : int (success_rate ),
71+ "Unit" : "Percent" ,
72+ },
6273 ]
6374
6475 # Use the put_metric_data method to push the metric data to CloudWatch
You can’t perform that action at this time.
0 commit comments