gitlab通过api创建组、项目、成员
2021-02-12 03:19
前戏
获取gitlab中admin用户的private_token
Groups API
获取某个组的详细
curl --header "PRIVATE-TOKEN: *********" http://192.168.10.7:8090/api/v4/groups/client #获取client组的详细信息
{ "id" : 6 , "name" : "client" , "path" : "client" , "description" : "客户端" , "visibility" : "private" , "lfs_enabled" :true, "avatar_url" :null, "web_url" : "http://192.168.10.7:8090/groups/client" , "request_access_enabled" :false, "full_name" : "client" , "full_path" : "client" , "parent_id" :null, "projects" :[], "shared_projects" :[]}
|
添加一个组
POST /groups
Parameters:
-
name
(required) - The name of the group #必须 -
path
(required) - The path of the group #必须 -
description
(optional) - The group‘s description -
membership_lock
(optional, boolean) - Prevent adding new members to project membership within this group -
share_with_group_lock
(optional, boolean) - Prevent sharing a project with another group within this group -
visibility
(optional) - The group‘s visibility. Can beprivate
,internal
, orpublic
. -
lfs_enabled
(optional) - Enable/disable Large File Storage (LFS) for the projects in this group -
request_access_enabled
(optional) - Allow users to request member access. -
parent_id
(optional) - The parent group id for creating nested group. -
shared_runners_minutes_limit
(optional) - (admin-only) Pipeline minutes quota for this group
curl --request POST --header "PRIVATE-TOKEN: *****" --data "name=shanxi&path=shanxi" http://192.168.10.7:8090/api/v4/groups; #添加山西组
添加一个子组
gitlab社区版在9.0以后增加了子组的功能,比如我在shanxi这个组下面添加taiyuan这个子组
curl --request POST --header "PRIVATE-TOKEN: ******" --data "name=taiyuan&path=taiyuan&parent_id=父组的id" http://192.168.10.7:8090/api/v4/groups;
User API
添加一个用户
curl -d "password=$password&email=$mail&username=$username&name=$name&private_token=************" http://192.168.10.7:8090/api/v4/users
Projects API
添加一个项目
加入shanxi组的id是4,我想在shanxi组下面创建一个majiang项目
curl --request POST --header "PRIVATE-TOKEN: *********" --data "name=majiang&namespace_id=4" http://192.168.10.7:8090/api/v4/projects
详细文档猛戳
https://docs.gitlab.com/ee/api/README.html
文章标题:gitlab通过api创建组、项目、成员
文章链接:http://soscw.com/index.php/essay/54287.html