-
Notifications
You must be signed in to change notification settings - Fork 8
/
gitlab_ci_builds
executable file
·31 lines (27 loc) · 1019 Bytes
/
gitlab_ci_builds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
from lib import get_gitlab_instance
import sys
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
print('graph_title GitLab CI build results')
print('graph_vlabel builds / second')
print('graph_args -l 0')
print('graph_category gitlab')
print('success.label successful')
print('success.type DERIVE')
print('success.draw AREA')
print('success.colour 00FF00')
print('failed.label failed')
print('failed.type DERIVE')
print('failed.draw STACK')
print('failed.colour FF0000')
print('canceled.label canceled')
print('canceled.type DERIVE')
print('canceled.draw STACK')
print('canceled.colour BBBBBB')
sys.exit(0)
gitlab = get_gitlab_instance()
db = gitlab.get_db_connection()
for state in ('success', 'failed', 'canceled'):
cursor = db.cursor()
cursor.execute("SELECT COUNT(*) FROM ci_builds WHERE status = '{state}'".format(state=state))
print('{state}.value {value}'.format(state=state, value=cursor.fetchone()[0]))