使用来自python的teamcity rest api
pyteamcit的Python项目详细描述
Pyteamcity
安装
pip install pyteamcity
新的api工作正在进行中
注意,我正在开发一个新的api pyteamcity.future (最初加入 #37)。
目标是创建一个全新的API,它更灵活,更容易实现。 有更好的代码,更容易使用。旧准则鼓励 为不同的过滤方法添加了无数的方法。新代码 有一个api,它包含的方法数量较少,并且更加一致 在过滤方面更灵活。它是模仿django orm 应用程序接口这个api还没有正式的文档,但是您应该能够 通过查看unit tests了解如何使用它。
我可能不会合并添加到旧api的prs, 因为我认为新的api是未来。我当然很感兴趣 在prs中添加新的api!
示例
连接到服务器
frompyteamcityimportTeamCity# This initialises the Client with the settings passed. <port> has to be an integer.tc=TeamCity('account','password','server',<port>)
或者不指定任何参数,它将从环境中读取设置 变量:
- TEAMCITY_USER
- TEAMCITY_PASSWORD
- TEAMCITY_HOST
- TEAMCITY_PORT(如果未设置,则默认为80)
frompyteamcityimportTeamCity# Initialises with environment variables: TEAMCITY_{USER,PASSWORD,HOST,PORT}tc=TeamCity()
获取数据
tc.get_projects()tc.get_project_by_project_id('MyProject')tc.get_all_users()tc.get_user_by_username('codyw')tc.get_all_vcs_roots()tc.get_all_build_types()tc.get_changes_by_build_id(73450)tc.get_build_statistics_by_build_id(73450)tc.get_build_tags_by_build_id(73450)tc.get_all_changes()tc.get_change_by_change_id(16884)tc.get_all_builds(start=0,count=3)tc.get_build_by_build_id(73450)tc.get_server_info()tc.get_agents()tc.get_all_plugins()
你也可以看看 sample.py 或 test_legacy.py
确认
这是一个经过大量修改的叉子 https://github.com/yotamoron/teamcity-python-rest-client非常感谢 是由于Yotam Oron