python3 獲取自建gitlab用戶提交信息


#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019-12-03 14:20
# @Author  : Anthony
# @Email   : xxxxx@163.com
# @File    : check_gitlab_log.py

# 注意 python-gitlab==1.4.0,該版本及該版本以下都支持v3,該版本以上只支持v4


import requests
import re
import time

url = "http://gitlab.test.cn/api/v3/projects?private_token=xxxxxxx&per_page=500"

response = requests.get(url=url)
#gitlab組名
p_group = ['spring-cloud-java']

data = response.json()
for i in data:
    if i['ssh_url_to_repo'].split(':')[1].split('/')[0] in p_group:
        # print(i)
        time.sleep(0.3)
     # 獲取每個項目下的信息
        r1 = requests.get('http://gitlab.test.cn/api/v3/projects/%d/repository/commits/master?private_token=xxxxxxx&per_page=1000'%i['id'])
        data2 = r1.json()
        print(i['path'],data2['author_name'],data2['created_at'],data2['message'])

'''
#獲取每個項目的信息
http://gitlab.test.cn/api/v3/projects?private_token=xxxxxxx-iB&per_page=100
#獲取每個項目下用戶信息
http://gitlab.test.cn/api/v3/projects/171/users?private_token=xxxxxxx&per_page=100

'''

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM