Created
June 23, 2020 17:11
-
-
Save azakordonets/d5b210a34136d98e1633acc26ff89c21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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