-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab-silicon-jobs.py
More file actions
executable file
·50 lines (38 loc) · 1.55 KB
/
gitlab-silicon-jobs.py
File metadata and controls
executable file
·50 lines (38 loc) · 1.55 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
import gitlab, os
CI_HOST = os.getenv("CI_SERVER_HOST")
if CI_HOST is None:
CI_HOST = "git.libretro.com"
PRIVATE_TOKEN = os.getenv("PRIVATE_TOKEN")
if PRIVATE_TOKEN is None:
print("Missing token!", flush=True)
gl = gitlab.Gitlab(url='https://' + CI_HOST, private_token=PRIVATE_TOKEN)
ci_groups = gl.groups.list(all=True)
for ci_group in ci_groups:
try:
group = gl.groups.get(ci_group.id)
except Exception as e:
continue
ci_available_projects = group.projects.list(all=True)
for project in ci_available_projects:
try:
parsed_project = gl.projects.get(project.id)
except Exception as e:
# print("Failed to fetch project: " + project.name, flush=True)
# print(str(e), flush=True)
continue
try:
pipeline = parsed_project.pipelines.latest()
except Exception as e:
# print("Failed to list pipelines for project: " + project.name, flush=True)
# print(str(e), flush=True)
continue
jobs = pipeline.jobs.list(all=True)
for job in jobs:
try:
if job.runner['id'] == 18 or job.runner['id'] == 14:
print(str(job.runner['id']) + ": " + group.name + "/" + project.name + ": " + job.name + " queued: " + str(job.queued_duration))
except Exception as e:
# print("Failed to deal with job: " + job.name + " for project: " + project.name, flush=True)
# print(str(e), flush=True)
continue