Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azakordonets/d5b210a34136d98e1633acc26ff89c21 to your computer and use it in GitHub Desktop.
Save azakordonets/d5b210a34136d98e1633acc26ff89c21 to your computer and use it in GitHub Desktop.
# 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