mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 10:28:06 +00:00
Add link to jenkins job from service-checks dashboard
Upgrade to distribute==0.6.49 Add templatetags Add link to jenkins job to service-checks dashbooard
This commit is contained in:
parent
ea7deb1586
commit
82546b1620
@ -1,22 +1,27 @@
|
||||
from datetime import datetime
|
||||
from os import environ as env
|
||||
|
||||
from django.conf import settings
|
||||
import requests
|
||||
from datetime import datetime
|
||||
from django.utils import timezone
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
import requests
|
||||
|
||||
logger = get_task_logger(__name__)
|
||||
|
||||
auth = (settings.JENKINS_USER, settings.JENKINS_PASS)
|
||||
|
||||
|
||||
def get_jenkins_url(jobname):
|
||||
return settings.JENKINS_API + 'job/%s/api/json' % jobname
|
||||
|
||||
|
||||
def get_job_status(jobname):
|
||||
ret = {
|
||||
'active': True,
|
||||
'succeeded': False,
|
||||
'blocked_build_time': None
|
||||
}
|
||||
endpoint = settings.JENKINS_API + 'job/%s/api/json' % jobname
|
||||
endpoint = get_jenkins_url(jobname)
|
||||
resp = requests.get(endpoint, auth=auth, verify=True)
|
||||
resp.raise_for_status()
|
||||
status = resp.json
|
||||
|
@ -497,7 +497,7 @@ class JenkinsStatusCheck(StatusCheck):
|
||||
|
||||
@property
|
||||
def check_category(self):
|
||||
return "Jenkins check"
|
||||
return 'Jenkins check'
|
||||
|
||||
@property
|
||||
def failing_short_status(self):
|
||||
|
0
app/cabotapp/templatetags/__init__.py
Normal file
0
app/cabotapp/templatetags/__init__.py
Normal file
9
app/cabotapp/templatetags/extra.py
Normal file
9
app/cabotapp/templatetags/extra.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django import template
|
||||
|
||||
from ..jenkins import get_jenkins_url
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.simple_tag
|
||||
def jenkins_url(jobname):
|
||||
return get_jenkins_url(jobname)
|
@ -3,8 +3,8 @@ from datetime import timedelta
|
||||
|
||||
BROKER_URL = os.environ['CELERY_BROKER_URL']
|
||||
CELERY_IMPORTS = ('app.cabotapp.tasks', )
|
||||
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
|
||||
CELERY_TASK_SERIALIZER = "json"
|
||||
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml']
|
||||
|
||||
CELERYBEAT_SCHEDULE = {
|
||||
|
@ -1,3 +1,5 @@
|
||||
{% load extra %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="col-xs-1"><h3><i class="{% if checks_type == "All" %}fa fa-cog{% else %}glyphicon glyphicon-{% if checks_type == "Http" %}arrow-up{% elif checks_type == "Jenkins" %}ok{% else %}signal{% endif %}{% endif %}"></i></h3></div>
|
||||
@ -59,7 +61,22 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
<td title="">
|
||||
{% if check.polymorphic_ctype.model == 'graphitestatuscheck' %}{{ check.metric|truncatechars:70 }} {{ check.check_type }} {{ check.value }}{% if check.expected_num_hosts %} (from {{ check.expected_num_hosts }} hosts){% endif %}{% elif check.polymorphic_ctype.model == 'httpstatuscheck' %}Status code {{ check.status_code }} from {{ check.endpoint }}{% if check.text_match %}; match text /{{ check.text_match }}/{% endif %}{% elif check.polymorphic_ctype.model == 'jenkinsstatuscheck' %}Monitor job {{ check.name }}{% if check.max_queued_build_time %}; check no build waiting for >{{ check.max_queued_build_time }} minutes{% endif %}{% endif %}
|
||||
{% if check.polymorphic_ctype.model == 'graphitestatuscheck' %}
|
||||
{{ check.metric|truncatechars:70 }} {{ check.check_type }} {{ check.value }}
|
||||
{% if check.expected_num_hosts %}
|
||||
(from {{ check.expected_num_hosts }} hosts)
|
||||
{% endif %}
|
||||
{% elif check.polymorphic_ctype.model == 'httpstatuscheck' %}
|
||||
Status code {{ check.status_code }} from {{ check.endpoint }}
|
||||
{% if check.text_match %}
|
||||
; match text /{{ check.text_match }}/
|
||||
{% endif %}
|
||||
{% elif check.polymorphic_ctype.model == 'jenkinsstatuscheck' %}
|
||||
Monitor job {{ check.name }}
|
||||
{% if check.max_queued_build_time %}
|
||||
; check no build waiting for >{{ check.max_queued_build_time }} minutes
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td title="Last result from {{ check.last_run|timesince }} ago (rightmost is newest)" class="text-right">
|
||||
{% if not check.recent_results %}
|
||||
@ -91,6 +108,11 @@
|
||||
<a class="btn btn-xs" href="{% url run-check pk=check.id %}">
|
||||
<i class="glyphicon glyphicon-refresh"></i><span class="break"></span>
|
||||
</a>
|
||||
{% if checks_type == "Jenkins" %}
|
||||
<a class="btn btn-xs" href="{% jenkins_url check.name %}">
|
||||
<i class="glyphicon glyphicon-link"></i><span class="break"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -2,8 +2,8 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
|
@ -6,7 +6,7 @@ anyjson==0.3.3
|
||||
argparse==1.2.1
|
||||
billiard==3.3.0.13
|
||||
celery==3.1.7
|
||||
distribute==0.6.24
|
||||
distribute==0.6.49
|
||||
dj-database-url==0.2.2
|
||||
django-appconf==0.6
|
||||
django-celery==3.1.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user