From ad406f7986e22b98d1622b444f67544c43e5d4c2 Mon Sep 17 00:00:00 2001 From: Aleksi Hietanen Date: Wed, 2 Nov 2016 13:43:52 +0200 Subject: [PATCH] Initial version for new combined build, testing and staging report script Change-Id: I93c34fc289df6afa5adaea89fcdb1b7f5e494cae --- scripts/GenerateBuildTestAndStagingReport.py | 161 +++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 scripts/GenerateBuildTestAndStagingReport.py diff --git a/scripts/GenerateBuildTestAndStagingReport.py b/scripts/GenerateBuildTestAndStagingReport.py new file mode 100644 index 0000000000..7b69b9825b --- /dev/null +++ b/scripts/GenerateBuildTestAndStagingReport.py @@ -0,0 +1,161 @@ +import argparse, requests, json, subprocess, re + +def createTableRow(*columns): + html = "" + for column in columns: + html += "" + column + "" + return html + "" + + +def getBuildStatusHtml(): + build_steps_request_string = "http://{}/app/rest/problemOccurrences?locator=build:{}".format(args.teamcityUrl, args.buildId) + build_steps_request = requests.get(build_steps_request_string, auth=(args.teamcityUser, args.teamcityPassword), headers={'Accept':'application/json'}) + if build_steps_request.status_code != 200: + return createTableRow(traffic_light.format(color="black"), "Build status: unable to retrieve status of build") + else: + build_steps_json = build_steps_request.json() + if build_steps_json["count"] == 0: + return createTableRow(traffic_light.format(color="green"), "Build status: all build steps successful") + else: + return createTableRow(traffic_light.format(color="red"), "Build status: there are failing build steps, check the build report".format(args.buildResultUrl)) + +def getTestStatusHtml(): + test_failures_request_string = "http://{}/app/rest/testOccurrences?locator=build:{},status:FAILURE".format(args.teamcityUrl, args.buildId) + test_failures_request = requests.get(test_failures_request_string, auth=(args.teamcityUser, args.teamcityPassword), headers={'Accept':'application/json'}) + if test_failures_request.status_code != 200: + return createTableRow(traffic_light.format(color="black"), "Test status: unable to retrieve status of tests") + else: + test_failures_json = test_failures_request.json() + if test_failures_json["count"] == 0: + return createTableRow(traffic_light.format(color="green"), "Test status: all tests passing") + else: + return createTableRow(traffic_light.format(color="red"), "Test status: there are " + str(test_failures_json["count"]) + " failing tests") +""" + if "testOccurrence" in test_failures_json: + ret += "

Failures:" + ret += "