[英]How to parse all the .gitlab-ci.yml files from all the repositories that i have access to?
How to parse all the.gitlab-ci.yml files from all the repositories that i have access to?如何解析我有权访问的所有存储库中的所有.gitlab-ci.yml 文件? I was searching documentation to do it using a python script but no luck.
我正在使用 python 脚本搜索文档,但没有运气。
Any suggestions are highly appreciated.任何建议都受到高度赞赏。 Thanks in advance guys!
提前谢谢各位!
You can do this by using the API.您可以使用 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 示例,因为我不知道 python,但我希望你知道他们该怎么做)
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.然后循环响应,并为每个项目使用存储库文件端点来获取 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那么你所需要的只是一个好的 YAML 解释器,这应该已经在这里得到了回答: 如何解析 Python 中的 YAML 文件
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 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.