程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Altassian | bitbucket Python API usage and implementation of related task automation

編輯:Python

This article summarizes how to invoke Altassian Of Bitbucket API And the realization of related task automation .
Updated: 2022 / 6 / 22


Altassian | Bitbucket Python API Implementation of automation of use and related tasks

  • Bitbucket Python API
  • stashy
  • atlassian-python-api
    • Bitbucket Module
      • Manage Projects
      • Repository
        • File
  • Reference link


Bitbucket Python API

At present, it is feasible Bitbucket API 12

  • stashy 34
  • python-bitbucket 5
  • atlassian-python-api 67

stashy

Login according to user name and password Bitbucket Server

from stashy
stash = stashy.connect()
url = 'http://YourServerAddr:7990',
username = 'YourUsername',
password = 'YourPassword')

atlassian-python-api

Bitbucket Module

Login according to user name and password Bitbucket Server

from atlassian import Bitbucket
bitbucket = Bitbucket(
url = 'http://YourServerAddr:7990',
username = 'YourUsername',
password = 'YourPassword')

Manage Projects

  • bitbucket.project.list()
bitbucket.project.list()
# {'key': ..., 'id': ..., 'name': ..., 'description': ..., 'public': ..., 'type': ..., 'links': {'self': [{'href': 'http://YourServerAdd:7990/projects/'key''}]}}
  • bitbucket.repo_list()
bitbucket.repo_list('YourProjectKey')
# {'slug': ..., 'id': ..., 'name': ..., 'description': ..., 'scmId': ..., 'state': ..., 'statusMessage': ..., 'forkable': ..., 'project': {'key': ..., 'id': ..., 'name': ..., 'description': ..., 'public': ..., 'type': ..., 'links': {'self': [{'href': 'http://YourServerAddr:7990/projects/YourProjectKey'}]}}, 'public': ..., 'links': {'clone': ..., [{'href': 'ssh://[email protected]: 7999/YourProjectKey/YourRepoSlug.git', 'name': 'ssh'}, {'href: 'http://YourServerAddr:7990/scm/YourProjectKey/YourReposlug.git', 'name': 'http'}], 'self': [{'href': 'http://YourServerAddr:7990/projects/YourProjectKey/repos/YourReposlug/browse'}]}
  • [x]

Repository

File

  • bitbucket.get_file_list(project_key, repository_slug, sub_folder, query, start, limit)
FileList = bitbucket.get_file_list(project_key = YourProjectKey, repository_slug = YourRepoSlug, sub_folder = YourFilePath, query = YourBranchName, start = FromwhereStart, limit=None)
# list(FileList) Can be listed in this Project The Repo The Branch The Subfolder Down from start All that started file name

  • bitbucket.get_content_file(project, repository, filename, at=None, markup=None)
FileCont = bitbucket.get_content_file(YourProjectKey, YourRepoSlug, YourFilePath&Name, YourBranch, markup=None)
type(FileCont)
# <class 'bytes'>
FILE = open('./FILE.csv', 'wb').write(FileCont)

  • bitbucket.download_repo_archive(project_key, repository_slug, dest_fd, at, filename, format, path, prefix, chunk_size)
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)
# perhaps 
# fd = open('./File', mode = 'wb')
# bitbucket.download_repo_archive(
# project_key = YourProjectKey,
# repository_slug = YourRepoSlug,
# dest_fd = Yourfd,
# at = YourBranch,
# path = YourFilePath&Name,
# format = zip)
# dest_fd.close()

Reference link


  1. python api for bitbucket︎

  2. Bitbucket API︎

  3. stashy︎

  4. stashy Github︎

  5. python-bitbucket︎

  6. atlassian-python-api︎

  7. atlassian-python-api Github︎


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved