gitlab通过api创建组、项目、成员

时间:2021-08-18 04:08:31

获取gitlab中admin用户的private_token

gitlab通过api创建组、项目、成员

Groups API 获取某个组的详细

curl --header "PRIVATE-TOKEN: *********" :8090/api/v4/groups/client   #获取client组的详细信息

client组的详细信息

{"id":6,"name":"client","path":"client","description":"客户端","visibility":"private","lfs_enabled":true,"avatar_url":null,"web_url":":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 be private, internal, or public.

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" :8090/api/v4/groups; #添加山西组

添加一个子组

gitlab社区版在9.0以后增加了子组的成果,好比我在shanxi这个组下面添加taiyuan这个子组

curl --request POST --header "PRIVATE-TOKEN: ******" --data "name=taiyuan&path=taiyuan&parent_id=父组的id" :8090/api/v4/groups;

User API 添加一个用户

curl  -d "password=$password&email=$mail&username=$username&name=$name&private_token=************" :8090/api/v4/users

Projects API 添加一个项目

插手shanxi组的id是4,我想在shanxi组下面创建一个majiang项目

curl --request POST --header "PRIVATE-TOKEN: *********" --data "name=majiang&namespace_id=4" :8090/api/v4/projects

详细文档猛戳

https://docs.gitlab.com/ee/api/README.html