Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# private token or personal token authentication
import gitlab
gl = gitlab.Gitlab('https://gitlab.com', 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 = []
gl.auth()
groups = gl.groups.list()
for group in groups:
group_name = group.attributes['name']
if 'GitLab.com' 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)
try:
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:
pass
for r in result:
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment