GitLab count total number of issues

天大地大妈咪最大 提交于 2020-05-14 20:15:46

问题


I would like to count all issues on my gitlab project using api.

Below the command that I'm using:

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.

We would like to bypass the pagination problem: the displayed results are always 100 (the max number).

How can we could get more than 100 ?

I would like to have as result only the total number of issue on my project.


回答1:


for anyone interestered I fixed it with this:

1) get the project ids of my gitlab

curl -s -L --header "PRIVATE-TOKEN:XXXXXX" "https://gitlab.XXXXX/api/v4/projects/"

combined with python -m json.tool and sed and jq and grep to get a list of ids and names.

then

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-Page"

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!



来源:https://stackoverflow.com/questions/48829255/gitlab-count-total-number-of-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!