From 1b7b68745569e903de7851b35f73d88795c1ff4a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 03 2017 16:50:55 +0000 Subject: Customize the commits.html template to show Atomic CI status With simple change, we now show a small banner with the results of each commit when it ran in the Atomic CI pipeline Signed-off-by: Pierre-Yves Chibon --- diff --git a/template/commits.html b/template/commits.html index 92a37dc..e01267d 100644 --- a/template/commits.html +++ b/template/commits.html @@ -6,6 +6,16 @@ repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %} {% set tag = "home" %} +{% block header %} + {{ super() }} + +{% endblock %} + {% block repo %}
{% if g.repo_obj and g.repo_obj.is_empty %} @@ -157,7 +167,9 @@ author=commit.author.email), cssclass="notblue")|safe}}
- {{ commit.hex|short }} + + {{ commit.hex|short }} +
{% endfor %} @@ -177,5 +189,37 @@ $('#diff_commits').toggle(); }); }); + {% if config.get('RESULTSDB_URL') %} + var _base_url = '{{ config.get("RESULTSDB_URL").rstrip("/") }}/api/v2.0/'; + var _url = _base_url + + "results/latest?repo=" + '{{ repo.name }}' + + "&namespace=" + '{{ repo.namespace }}' + + "&testcases=org.centos.prod.ci.pipeline.complete"; + var listItems = $(".commithash"); + listItems.each(function(idx, li) { + var _id = $(li).attr('id'); + var _h = _id.substring(2) + $.ajax({ + url: _url + '&rev=' + _h, + type: 'GET', + dataType: 'jsonp', + success: function(res) { + var el = $(li); + ref_url = res.data[0]['ref_url']; + status = res.data[0]['outcome']; + var _lbl = 'red'; + if (status == 'PASSED') { + _lbl = '#06ea10'; + } + var html = '\ + \ + '; + el.after(html); + } + }); + }); + {% endif %} {% endblock %}