简体   繁体   English

如何解析我有权访问的所有存储库中的所有.gitlab-ci.yml 文件?

[英]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.

相关问题 我的 first.gitlab-ci.yml 文件:如何在 CI/CD 中运行现有文件 - My first .gitlab-ci.yml file: How to run existing files in CI/CD 如何在 Gitlab 中为简单的 hello world 程序配置 gitlab-ci.yml - How do I configure gitlab-ci.yml for a simple hello world program in Gitlab 如何在 gitlab-ci.yml 中将 postgis 扩展添加到 postgresql 数据库 - How to add postgis extension to postgresql database in gitlab-ci.yml 如何从 .gitlab-ci.yml 文件中提取单个管道名称? - How to extract individual Pipeline names from .gitlab-ci.yml file? 在Gitlab中配置.gitlab-ci.yml文件以测试python代码 - Configuring .gitlab-ci.yml file in Gitlab to test python Codes 如何避免在.gitlab-ci.yml的每个阶段之前安装requirements.txt? - How to avoid installing requirements.txt before every stage in .gitlab-ci.yml? Gitlabci 管道失败:gitlab-ci.yml 中规则中的语法错误 - Gitlabci pipline failes with: syntax error in rules in gitlab-ci.yml gitlab-ci.yml:“脚本:-pytest”命令无法识别 - gitlab-ci.yml: 'script: -pytest' command is not recognized gitlab-ci.yml python -c'多行cmd'失败 - gitlab-ci.yml python -c 'multiple line cmd' failed 使用 pyyaml 的 Load.gitlab-ci.yml 失败,无法确定构造函数 - Load .gitlab-ci.yml with pyyaml fails with could not determine constructor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM