I would like to get a list of all projects in a group, where the last pipeline has not succeeded.
My current code:
def failed_pipelines(groupid):
g = gitlab.Gitlab('https://gitlab.com', private_token=GITLAB_API_TOKEN)
group = g.groups.get(id=groupid)
for group_proj in group.projects.list(archived=False, simple=True, as_list=False):
project = g.projects.get(id=group_proj.id)
pipelines = project.pipelines.list(page=1, per_page=1)
if not pipelines:
continue
if pipelines[0].status != 'success':
yield project.name
works, but takes 70+ seconds on 132 projects.
Is there a better/faster way?