Install pip install python-gitlab
then run the script. It generates csv which includes full_path, http_url_to_repo and compliance_frameworks.
generate.py
from gitlab import Gitlab
import csv
gitlab_token = "<<my_token>>"
root_group_name = "<<group_name>>>"
output_file_name = "gitlab_compliancy_labels.csv"
gl = Gitlab(private_token=gitlab_token)
gl.auth()
# gl.enable_debug()
with open(output_file_name, "w", newline="") as csvfile:
writer = csv.writer(csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL)
group = gl.groups.get(root_group_name)
projects = group.projects.list(archived=0, order_by="path", include_subgroups=True, all=True)
writer.writerow(["path", "git_url", "compliance_frameworks"])
for project in projects:
compliance_frameworks = project.attributes.get("compliance_frameworks")
name = project.attributes.get("namespace")["full_path"]
git_url = project.attributes.get("http_url_to_repo")
writer.writerow([name, git_url, "|".join(compliance_frameworks)])
Top comments (0)