前戏
获取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 descriptionmembership_lock
(optional, boolean) - Prevent adding new members to project membership within this groupshare_with_group_lock
(optional, boolean) - Prevent sharing a project with another group within this groupvisibility
(optional) - The group‘s visibility. Can beprivate
,internal
, orpublic
.lfs_enabled
(optional) - Enable/disable Large File Storage (LFS) for the projects in this grouprequest_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