docker gitlab and gitlab api

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

curl --header "PRIVATE-TOKEN: fxhDXPRJAowCouXEobrz" "http://localhost/api/v4/repositories"


curl --header "PRIVATE-TOKEN: W72WXtZCW6hGmyPT_meU" "http://git.unipus.cn/api/v4/projects"

_这个地址访问获取的项目数量是20个,最后一下项目的显示下标是19,之所以没有展示完所有项目,是因为gitlab api默认做了分页处理,如果不建入分页参数,会默认只显示20条,用下面的地址访问,就可以显示更多项目了:
https://git.ynpay.cc/api/v3/projects/all?per_page=100&page=1?private_token=XXXXXX

perpage max is 100


curl --header "PRIVATE-TOKEN: W72WXtZCW6hGmyPT_meU" "http://git.unipus.cn/api/v4/projects?per_page=100&page=1" > a1.txt


curl --header "PRIVATE-TOKEN: W72WXtZCW6hGmyPT_meU" "http://git.unipus.cn/api/v4/projects?per_page=100&page=2" > a2.txt


import requests
url = 'http://git.unipus.cn/api/v4/projects?private_token=W72WXtZCW6hGmyPT_meU'
res = requests.get(url)
if res.status_code != 200:
raise ServerError(res.get('message'))

data = res.json()
for i in data:
print i,i[u'ssh_url_to_repo']

print "all success"

 

import json
filename = 'a2.txt'
with open(filename) as f:
gpd_list = json.load(f)
# 遍历列表的每个元素,每个元素是一个GDP数据项


for gpd_dict in gpd_list:
print gpd_dict['id'],gpd_dict['description'],gpd_dict['ssh_url_to_repo']

 

install gitlab as docker
https://www.jianshu.com/p/24959481340e
https://www.cnblogs.com/zuxing/articles/9329152.html

gitlab docker
docker pull gitlab/gitlab-ce:latest
mkdir -p gitlab/config
mkdir -p gitlab/logs
mkdir -p gitlab/data

--hostname localhost \

sudo docker run --detach \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /opt/dockerRoot/dockerData/gitlab/config:/etc/gitlab \
--volume /opt/dockerRoot/dockerData/gitlab/logs:/var/log/gitlab \
--volume /opt/dockerRoot/dockerData/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest


Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

docker exec -it gitlab vim /etc/gitlab/gitlab.rb
docker restart gitlab

docker exec -it gitlab vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml


For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

docker exec -it gitlab update-permissions
docker restart gitlab

posted on 2019-12-02 14:40  szllq2000  阅读(453)  评论(0编辑  收藏  举报