gitlabユーザーIDの表示

5345 ワード

需要
gitlabユーザーのidを表示する必要があります
方法1
ページapiでクエリーhttp://10.18.13.100:10080/api/v4/users?username=test101 gitlab查看用户id_第1张图片
方法2
gitlabデータベースクエリーにアクセスし、gitlabはdockerを使用して配置されるため、コンテナ操作にアクセスする必要があります.
root@10-18-13-100:~# docker ps | grep gitlab
9178130d2c2a        10.253.127.117:8080/gitlab/gitlab-ce:10.5.2-ce.0      "/.r/r /assets/wra..."   2 months ago        Up 2 months (healthy)                                                                          r-gitlab-gitlab-server-1-ca83b62b
root@10-18-13-100:~# 
root@10-18-13-100:~# 
root@10-18-13-100:~# docker exec -it  9178 bash
root@gitlab-gitlab-server-1:/# 

データベースの操作
root@gitlab-gitlab-server-1:/# gitlab-rails dbconsole
psql (9.6.5)
Type "help" for help.
##      
gitlabhq_production=> \l 
                                         List of databases
        Name         |    Owner    | Encoding | Collate |  Ctype  |        Access privileges        
---------------------+-------------+----------+---------+---------+---------------------------------
 gitlabhq_production | gitlab      | UTF8     | C.UTF-8 | C.UTF-8 | 
 postgres            | gitlab-psql | UTF8     | C.UTF-8 | C.UTF-8 | 
 template0           | gitlab-psql | UTF8     | C.UTF-8 | C.UTF-8 | =c/"gitlab-psql"               +
                     |             |          |         |         | "gitlab-psql"=CTc/"gitlab-psql"
 template1           | gitlab-psql | UTF8     | C.UTF-8 | C.UTF-8 | =c/"gitlab-psql"               +
                     |             |          |         |         | "gitlab-psql"=CTc/"gitlab-psql"
(4 rows)

gitlabhq_production=> 
##      
gitlabhq_production=> \c gitlabhq_production 
You are now connected to database "gitlabhq_production" as user "gitlab".
gitlabhq_production=> 
##     id
gitlabhq_production=> select id from users where name = 'test101';
 id 
----
 19
(1 row)