与gitlab api交互
python-gitlab的Python项目详细描述
python gitlab
python-gitlab是一个python包,提供对gitlab服务器api的访问。
它支持gitlab的v4 api,并提供一个cli工具(gitlab)。
使用python gitlab docker图像
如何构建
docker build -tpython-gitlab:TAG .
如何使用
docker run -it--rm-eGITLAB_PRIVATE_TOKEN=<your token> -v/path/to/python-gitlab.cfg:/python-gitlab.cfgpython-gitlab <command> ...
或者直接从上游图像运行:
docker run -it--rm-eGITLAB_PRIVATE_TOKEN=<your token> -v/path/to/python-gitlab.cfg:/python-gitlab.cfgregistry.gitlab.com/python-gitlab/python-gitlab:v1.8.0 <command> ...
要更改gitlab url,请使用-e gitlab_url=<;您的url>;
自带配置文件: docker run -it--rm-v/path/to/python-gitlab.cfg:/python-gitlab.cfg-eGITLAB_CFG=/python-gitlab.cfgpython-gitlab <command> ...
错误报告
请在报告错误和功能请求 https://github.com/python-gitlab/python-gitlab/issues。
贡献
您可以通过多种方式为项目做出贡献:
- 编写文档
- 实现功能
- 修复错误
- 添加单元和功能测试
- 你能想到的一切
我们强制使用conventional-changelog格式化提交消息。 这将导致在查看项目历史记录时更易于理解的消息。
请按照github pull请求提供修补程序。谢谢!
代码样式
我们使用黑色作为代码格式化程序,因此您需要使用 black code formatter。
只需运行
cd python-gitlab/
pip3 install --user black
black .
根据我们的指导来格式化你的代码。
运行单元测试
在提交pull请求之前,请确保测试仍然成功 你的零钱。单元测试和功能测试使用travis服务和 必须通过测试才能接受合并请求。
您需要安装tox才能在本地运行单元测试和文档生成:
# run the unit tests for python 2/3, and the pep8 tests: tox # run tests in one environment only: tox -epy35 # build the documentation, the result will be generated in # build/sphinx/html/ tox -edocs
运行集成测试
两个脚本使用docker对正在运行的gitlab实例运行测试 集装箱。你需要在测试机器上安装Docker,你的用户 必须具有与Docker守护进程对话的正确权限。
要运行这些测试:
# run the CLI tests: ./tools/functional_tests.sh # run the python API tests: ./tools/py_functional_tests.sh
还可以使用以下命令构建测试环境:
./tools/build_test_env.sh
新配置的gitlab容器将在 http://localhost:8080(登录root/密码5iveL!fe)。配置 对于python,gitlab将用/tmp/python-gitlab.cfg编写。
要清除环境,请删除容器:
docker rm -f gitlab-test