-1

How to parse all the .gitlab-ci.yml files from all the repositories that i have access to? I was searching documentation to do it using a python script but no luck.

Any suggestions are highly appreciated. Thanks in advance guys!

1 Answers1

1

You can do this by using the API.

First, you retrieve all projects, using the projects endpoint. Should be something like this (these are curl examples, as I don't know python, but I expect you know what to do by them)

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects?membership=true"

Then you loop over the response, and for each project you use the repository files endpoint to get the gitlab-ci.yaml.

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/gitlab-ci%2Eyaml?ref=master"

Then all you need is a good YAML interpreter, and that should be already answered here: How can I parse a YAML file in Python

Edit: For those who, like me, don't know python, this seems to be a helpful explanation in how to call a restful API in python: Making a request to a RESTful API using python