From a1ffd67967a9b7718d48f3df1a01cdf35830b520 Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Tue, 9 Apr 2019 14:14:02 -0700 Subject: [PATCH 1/8] Adding tile structure --- src/main/resources/synthetic.xml | 27 ++++++++++++++ .../project-status-tile-summary-view.html | 35 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html diff --git a/src/main/resources/synthetic.xml b/src/main/resources/synthetic.xml index d98009a..ba0a899 100644 --- a/src/main/resources/synthetic.xml +++ b/src/main/resources/synthetic.xml @@ -103,4 +103,31 @@ + + + diff --git a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html new file mode 100644 index 0000000..050f26f --- /dev/null +++ b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html @@ -0,0 +1,35 @@ + + + + + + +
+ + + \ No newline at end of file From 7de2d6f8e237b3c8bd0f8003f91aec520a85f461 Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Tue, 9 Apr 2019 17:22:48 -0700 Subject: [PATCH 2/8] echarts example --- .../project-status-tile-summary-view.html | 63 ++++++++++--------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html index 050f26f..63ec5b4 100644 --- a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html +++ b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html @@ -1,35 +1,40 @@ - + - + + ECharts + + -
- + +
+ \ No newline at end of file From b6d0aa9a3fd6a6b0683461aecd4a9feb08eb6f0a Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Tue, 9 Apr 2019 21:49:53 -0700 Subject: [PATCH 3/8] Converted to pie chart --- .../teamcity/BuildConfigurationsStatusTile.py | 5 +- .../project-status-tile-summary-view.html | 46 ++++++++++++++----- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py index ca8ecf9..e4c546c 100644 --- a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py +++ b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py @@ -8,12 +8,11 @@ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -import logging - from dateutil.parser import parse +from org.slf4j import Logger, LoggerFactory from teamcity import TeamCityClient -logger = logging.getLogger("TeamCity") +logger = LoggerFactory.getLogger("com.xebialabs") logger.info("Executing BuildConfigurationsStatusTile") data = {} if teamcityServer: diff --git a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html index 63ec5b4..c80c3ba 100644 --- a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html +++ b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html @@ -1,11 +1,13 @@ + ECharts +
@@ -16,25 +18,45 @@ // specify chart configuration item and data var option = { title: { - text: 'ECharts entry example' + text: 'TeamCity Project Overview', + x: 'center' }, - tooltip: {}, - legend: { - data:['Sales'] + tooltip: { + trigger: 'item', + formatter: "{a}
{b} : {c} ({d}%)" }, - xAxis: { - data: ["shirt","cardign","chiffon shirt","pants","heels","socks"] + legend: { + orient: 'horizontal', + bottom: 'bottom', + data: ['Success', 'Failed', 'Cancelled', 'No runs', 'Unknown'] }, - yAxis: {}, - series: [{ - name: 'Sales', - type: 'bar', - data: [5, 20, 36, 10, 10, 20] - }] + series: [ + { + name: 'Statuses', + type: 'pie', + radius: '55%', + center: ['50%', '60%'], + data: [ + { value: 335, name: 'Success' }, + { value: 310, name: 'Failed' }, + { value: 234, name: 'Cancelled' }, + { value: 135, name: 'No runs' }, + { value: 1548, name: 'Unknown' } + ], + itemStyle: { + emphasis: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + } + ] }; // use configuration item and data specified to show chart myChart.setOption(option); + \ No newline at end of file From 17319e33ddb337cab9d26c99858241ec8d889a13 Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Tue, 9 Apr 2019 22:24:18 -0700 Subject: [PATCH 4/8] Using real data --- .../teamcity/BuildConfigurationsStatusTile.py | 16 +++- ...nfigurations-status-tile-summary-view.html | 2 +- .../project-status-tile-summary-view.html | 82 +++++++++---------- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py index e4c546c..feba9ff 100644 --- a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py +++ b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py @@ -15,6 +15,18 @@ logger = LoggerFactory.getLogger("com.xebialabs") logger.info("Executing BuildConfigurationsStatusTile") data = {} +status_count = [] +status_options = [] + +def increment_status_count(status): + if status not in status_options: + status_options.append(status) + if not any(d['name'] == status for d in status_count): + status_count.append({'name':status,'value':0}) + d = next(d for i,d in enumerate(status_count) if d['name'] == status) + d['value'] += 1 + logger.info("status_count [%s]" % status_count) + if teamcityServer: teamcity_client = TeamCityClient( teamcityServer, username=None, password=None, logger=logger) @@ -42,6 +54,7 @@ "statusText": "No builds to display", "problemOccurrences": {}, "testOccurrences": {}, "finishDate": "N/A", "statusUrl": "%s/app/rest/builds/buildType:(id:%s)/statusIcon" % (teamcityServer["url"], build_configuration['id'])}) + increment_status_count("No Info") else: build_problem_occurrences = teamcity_client.get_build_problem_occurrences( build_configuration['builds']['build'][0]['id']) @@ -66,4 +79,5 @@ "buildLog": processed_build_log, "statusUrl": "%s/app/rest/builds/buildType:(id:%s)/statusIcon" % (teamcityServer["url"], build_configuration['id']), "buildLogUrl": "%s/downloadBuildLog.html?buildId=%s" % (teamcityServer["url"], build_configuration['builds']['build'][0]['id'])}) - data = {"projectStatuses": project_statuses} + increment_status_count(build_configuration['builds']['build'][0]['status']) + data = {"projectStatuses": project_statuses, "statusCount": status_count, "statusOptions": status_options} diff --git a/src/main/resources/web/teamcity/BuildConfigurationsStatusTile/build-configurations-status-tile-summary-view.html b/src/main/resources/web/teamcity/BuildConfigurationsStatusTile/build-configurations-status-tile-summary-view.html index 473c1e7..562a74b 100644 --- a/src/main/resources/web/teamcity/BuildConfigurationsStatusTile/build-configurations-status-tile-summary-view.html +++ b/src/main/resources/web/teamcity/BuildConfigurationsStatusTile/build-configurations-status-tile-summary-view.html @@ -108,7 +108,7 @@ - }) + }); diff --git a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html index c80c3ba..6fb3418 100644 --- a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html +++ b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html @@ -12,50 +12,50 @@
From 4620035050bb923265f12bbce43d7c36a82be038 Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Tue, 9 Apr 2019 22:34:58 -0700 Subject: [PATCH 5/8] Initial take on hard coding colors --- src/main/resources/teamcity/BuildConfigurationsStatusTile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py index feba9ff..5ecb09b 100644 --- a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py +++ b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py @@ -17,12 +17,13 @@ data = {} status_count = [] status_options = [] +status_colors = {'SUCCESS':'green','UNKNOWN':'orange','FAILURE':'red','No Info':'gray'} def increment_status_count(status): if status not in status_options: status_options.append(status) if not any(d['name'] == status for d in status_count): - status_count.append({'name':status,'value':0}) + status_count.append({'name':status,'value':0, 'itemStyle':{'color':status_colors[status]}}) d = next(d for i,d in enumerate(status_count) if d['name'] == status) d['value'] += 1 logger.info("status_count [%s]" % status_count) From c8c4d6e0b4e6f8fa0c8b427d2a77ab7afa9f190f Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Wed, 10 Apr 2019 07:14:32 -0700 Subject: [PATCH 6/8] Taking into account an unknown status to be shown as red --- src/main/resources/teamcity/BuildConfigurationsStatusTile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py index 5ecb09b..2132e63 100644 --- a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py +++ b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py @@ -23,7 +23,7 @@ def increment_status_count(status): if status not in status_options: status_options.append(status) if not any(d['name'] == status for d in status_count): - status_count.append({'name':status,'value':0, 'itemStyle':{'color':status_colors[status]}}) + status_count.append({'name':status,'value':0, 'itemStyle':{'color':status_colors[status] if status in status_colors else 'red'}}) d = next(d for i,d in enumerate(status_count) if d['name'] == status) d['value'] += 1 logger.info("status_count [%s]" % status_count) From 39c414a4199d2923f6ab4f67bf53813d8a6dd603 Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Wed, 10 Apr 2019 07:15:51 -0700 Subject: [PATCH 7/8] Adding license --- .../project-status-tile-summary-view.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html index 6fb3418..5930750 100644 --- a/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html +++ b/src/main/resources/web/teamcity/ProjectStatusTile/project-status-tile-summary-view.html @@ -1,3 +1,14 @@ + From 354eef2c9181d1e2b93da81d71ebce3566d1ac6f Mon Sep 17 00:00:00 2001 From: Joris De Winne Date: Wed, 10 Apr 2019 07:28:31 -0700 Subject: [PATCH 8/8] Removing unused import --- src/main/resources/teamcity/BuildConfigurationsStatusTile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py index 2132e63..aef2afd 100644 --- a/src/main/resources/teamcity/BuildConfigurationsStatusTile.py +++ b/src/main/resources/teamcity/BuildConfigurationsStatusTile.py @@ -9,7 +9,7 @@ # from dateutil.parser import parse -from org.slf4j import Logger, LoggerFactory +from org.slf4j import LoggerFactory from teamcity import TeamCityClient logger = LoggerFactory.getLogger("com.xebialabs")