本文总结如何调用Altassian的Bitbucket API及相关任务自动化的实现。 Updated: 2022 / 6 / 22
Altassian | Bitbucket Python API使用及相关任务自动化的实现
Bitbucket Python API
目前可行的Bitbucket API ’
stashy
根据用户名和密码登录Bitbucket Server
from stashy
stash = stashy.connect()
url = 'http://YourServerAddr:7990',
username = 'YourUsername',
password = 'YourPassword')
atlassian-python-api
Bitbucket Module
根据用户名和密码登录Bitbucket Server
from atlassian import Bitbucket
bitbucket = Bitbucket(
url = 'http://YourServerAddr:7990',
username = 'YourUsername',
password = 'YourPassword')
Manage Projects
bitbucket.project.list()
bitbucket.repo_list('YourProjectKey')
Repository
File
FileList = bitbucket.get_file_list(project_key = YourProjectKey, repository_slug = YourRepoSlug, sub_folder = YourFilePath, query = YourBranchName, start = FromwhereStart, limit=None)
FileCont = bitbucket.get_content_file(YourProjectKey, YourRepoSlug, YourFilePath&Name, YourBranch, markup=None)
type(FileCont)
FILE = open('./FILE.csv', 'wb').write(FileCont)
with open('./File', mode='wb') as Yourfd:
bitbucket.download_repo_archive(
project_key = YourProjectKey,
repository_slug = YourRepoSlug,
dest_fd = Yourfd,
at = YourBranch,
path = YourFilePath&Name,
format = zip)
参考链接
|