GitLab 统计问题总数 [英] GitLab count total number of issues
问题描述
我想使用 api 计算我的 gitlab 项目中的所有问题.
I would like to count all issues on my gitlab project using api.
在我使用的命令下方:
curl --header "PRIVATE-TOKEN:xxxxxxx" https://gitlab.myapp.com/api/v4/groups/xx/issues?scope=all
我也尝试用项目替换组.
I've also tried to replace groups with project.
我们想绕过分页问题:显示的结果总是 100(最大数量).
We would like to bypass the pagination problem: the displayed results are always 100 (the max number).
我们怎样才能得到超过 100 个?
How can we could get more than 100 ?
我只想得到我项目中的问题总数.
I would like to have as result only the total number of issue on my project.
推荐答案
对于任何有兴趣的人,我用这个修复了它:
for anyone interestered I fixed it with this:
获取我的 gitlab 的项目 ID
get the project ids of my gitlab
curl -s -L --header "PRIVATE-TOKEN:XXXXXX";"https://gitlab.XXXXX/api/v4/projects/"
curl -s -L --header "PRIVATE-TOKEN:XXXXXX" "https://gitlab.XXXXX/api/v4/projects/"
结合 python -m json.tool
和 sed
和 jq
和 grep
得到一个列表ID 和名称.
combined with python -m json.tool
and sed
and jq
and grep
to get a list of ids and names.
然后
我得到了项目 ID 的问题总页数
I get the number of total pages of issues for project ids
curl -s --head --header "PRIVATE-TOKEN:XXXXXX" "https://gitlab.XXXXX/api/v4/projects/${id}/issues?state=all&per_pages=100"
| grep "X-Total-Pages"
然后我用 while
循环提取所有问题:
then I extract all the issues with a while
cycle:
curl -s --header "PRIVATE-TOKEN:XXXXX" "https://gitlab.XXXX/api/v4/projects/${id}/issues?scope=all&state=all&label_name\[\]=BU
G&page=${i}&per_page=100"
$i is the page counter
我希望这可以帮助其他人!
I hope this could help someone else!
如果您有任何问题,请随时提问!
If you have questions, feel free to ask!
这篇关于GitLab 统计问题总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!