gitlab安装及接口调用示例

本文档详细介绍了GitLab的安装步骤,参考了相关技术博客,并提供了完成安装后的API接口调用实例,包括API文档的访问地址以及Python3的调用示例。
摘要由CSDN通过智能技术生成

gitlab安装

参考文章

https://zhuanlan.zhihu.com/p/547052294
https://blog.csdn.net/dqfe123/article/details/122295781

# 系统 centos7

# 测试机关闭防火墙
systemctl stop firewalld && systemctl disable firewalld

# 安装依赖并运行postfix
yum -y install curl policycoreutils openssh-server openssh-clients postfix policycoreutils-python
systemctl start postfix

# gitlab包下载
wget http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm

# rpm安装
rpm -ivh gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm	

# 配置项修改,测试安装,修改 external_url
vim  /etc/gitlab/gitlab.rb



# 密码文件,第一次安装root密码存放位置
/etc/gitlab/initial_root_password



# 重载服务
gitlab-ctl reconfigure 
# gitlab-ctl restart
#查看状态
gitlab-ctl status 


接口调用实例

这里gitlab安装完成后,api文档地址为 http://localip/help/api/api_resources.md

python3调用

import json
import base64
import requests



class MyGitlabApi():
    def __init__(self) -> None:
        self.url = "http://localip/"
        self.session = requests.session()
        self.header = {
   
            "Private-Token":"" # token
        }

    
    def projects(self):
        """
        获取用户的projects信息
        """
        url = self.url +"api/v4/projects/?per_page=100&page=1"
        ret = self.session.get(url,headers = self.header)
        # print(ret.status_code)
        if 200 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值