机器人 救救瓜
Toggle navigation
Home
SCM-tool
Linux
Jenkins
SVN
other
About Me
Archives
Tags
使用gitlab API 与jq 筛选器 查找信息的例子
? gitlab ?
2021-01-06 15:19:23
1062
0
0
gua_l
? gitlab ?
https://docs.gitlab.com/ee/api/README.html https://stedolan.github.io/jq/manual/#Invokingjq P_token: ``` gitlab web : User Setting --> Access Tokens ``` API_VERSION: ``` https://gitlab.casa-systems.com/help/api/v3_to_v4.md In GitLab 9.0 and later, API V4 is the preferred version to be used. ``` jq command: ``` https://stedolan.github.io/jq/manual/#Invokingjq ``` <br> <br> ### gitlab api 根据指定组名取组对象 ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq . ``` ### gitlab api 根据指定组名取组里的元素属性 ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq 'keys' ``` ### gitlab api 根据指定组名取组里的第一个project里的属性 ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .projects[0]|jq 'keys' ``` ### gitlab api 根据指定组名取组的任一key的值 ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .id curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .name curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .web_url curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .projects ``` ### gitlab api 根据指定组名取组的任N个key的值,使用{} ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq '{id,name,web_url}' ``` ### gitlab api 根据指定组名取组的任N个key的值,并指定打印的keyname ``` curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq '{groupid:.id,groupname:.name, web_url,projectname:.projects[].name}' ```
Pre:
shell 里awk 的用法
Next:
使用winscp 从 linux server 到 win7 的定时下载任务
0
likes
1062
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.