简体   繁体   English

通过Python的Bitbucket服务器REST API

[英]Bitbucket server REST API via Python

I would like to use the REST API service of Bitbucket server in Python. 我想在Python中使用Bitbucket服务器的REST API服务。 Till now I tried the python module called stashy, but I could not even connect. 直到现在,我尝试了名为stashy的python模块,但我什至无法连接。 The snippet 片段

import stashy
stash = stashy.connect("http://localhost:7990/stash", "<user>", "<pass>")
stash.admin.groups.list()

raises the exception 引发异常

stashy.errors.GenericException: Unknown error: 503(Service Unavailable)

By simply running a GET request via curl 只需通过curl运行GET请求

curl -u <user>:<pass> http://127.0.0.1:7990/stash

I get a page, which shows I am logged in. 我得到一个页面,该页面显示我已登录。

My environment: 我的环境:

Python: 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516] Python:2.7.13(默认值,2017年11月24日,17:33:09)[GCC 6.3.0 20170516]

Bitbucket: Atlassian Bitbucket v5.13.0 Bitbucket:Atlassian Bitbucket v5.13.0

Thanks! 谢谢!

The example connection URL of "http://localhost:7990/stash" in the stashy docs is just an example. stashy文档中的示例连接URL "http://localhost:7990/stash"仅是示例。 If you want to connect to a "real" instance of Bitbucket Server, you need to change that URL accordingly. 如果要连接到Bitbucket Server的“真实”实例,则需要相应地更改该URL。

Just visit your Bitbucket Server site in a web browser and copy the first part of the URL. 只需在网络浏览器中访问您的Bitbucket Server网站,然后复制URL的第一部分即可。 It's probably something like https://bitbucket.mycompany.com , and use the same username and password as you'd use via your web browser. 可能类似于https://bitbucket.mycompany.com ,并使用与您通过网络浏览器使用的用户名和密码相同的用户名和密码。

stash = stashy.connect("https://bitbucket.mycompany.com", "myusername", "mypassword")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM