Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# private token or personal token authentication
import gitlab
gl = gitlab.Gitlab('', private_token='{your_token}')
# make an API request to create the gl.user object. This is mandatory if you
# use the username/password authentication.
result = []
groups = gl.groups.list()
for group in groups:
group_name = group.attributes['name']
if '' not in str(group_name):
projects = group.projects.list(all=True)
for prj in projects:
project_name = prj.attributes['name']
print(f"Processing {group_name}: {project_name}")
id = prj.attributes['id']
project = gl.projects.get(id)
file = str(project.files.raw(file_path='.gitlab-ci.yml', ref='master')).split('\\n')
for f in file:
if 'image:' in f:
result.append((group_name, prj.attributes['name'], f))
except Exception as e:
for r in result:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment