返回介绍

2.5.15.5. BitbucketStatusPush

发布于 2023-09-20 23:50:39 字数 4865 浏览 0 评论 0 收藏 0

Caution

Buildbot no longer supports Python 2.7 on the Buildbot master.

2.5.15.5. BitbucketStatusPush

from buildbot.plugins import reporters

c['services'].append(reporters.BitbucketStatusPush('oauth_key', 'oauth_secret'))

BitbucketStatusPush publishes build status using the Bitbucket Build Status API. The build status is published to a specific commit SHA in Bitbucket. By default, it tracks the last build for each builder and each commit built.

It requires txrequests package to allow interaction with the Bitbucket REST and OAuth APIs.

It uses OAuth 2.x to authenticate with Bitbucket. To enable this, you need to go to your Bitbucket Settings -> OAuth page. Click “Add consumer”. Give the new consumer a name, e.g. buildbot, and put in any URL as the callback (this is needed for Oauth 2.x, but it’s not used by this reporter), e.g. http://localhost:8010/callback. Give the consumer Repositories:Write access. After creating the consumer, you will then be able to see the OAuth key and secret.

class buildbot.reporters.bitbucket.BitbucketStatusPush(oauth_key=None, oauth_secret=None, auth=None, base_url='https://api.bitbucket.org/2.0/repositories', oauth_url='https://bitbucket.org/site/oauth2/access_token', status_key=None, status_name=None, generators=None)
Parameters:
  • oauth_key (string) – The OAuth consumer key, when using OAuth to authenticate (can be a Secret)

  • oauth_secret (string) – The OAuth consumer secret, when using OAuth to authenticate (can be a Secret)

  • auth (string) – The username,password tuple if using App passwords to authenticate (can be a Secret)

  • base_url (string) – Bitbucket’s Build Status API URL

  • oauth_url (string) – Bitbucket’s OAuth API URL

  • status_key (string) – Key that identifies a build status. Setting the key to a unique value per build allows to push multiple build statuses to a given commit. A static string can be passed or Interpolate for dynamic substitution. The default key is %(prop:buildername)s

  • status_name (string) – Name of a build status. It shows up next to the status icon in Bitbucket. A static string can be passed or Interpolate for dynamic substitution. The default name is %(prop:buildername)s

  • generators – A list of report generators that will be used to generate reports to be sent by this reporter. Currently the reporter will consider only the report generated by the first generator. The subject of the report will be used to set the description of the build status. The default subject is an empty string

  • verify (boolean) – Disable ssl verification for the case you use temporary self signed certificates

  • debug (boolean) – Logs every requests and their response

For example, the following reporter

from buildbot.plugins import reporters

reporters.BitbucketStatusPush(
    'oauth_key', 'oauth_secret',
    status_key=Interpolate("%(prop:buildername)s/%(prop:buildnumber)s"),
    status_name=Interpolate("%(prop:buildername)s/%(prop:buildnumber)s"),
    generators=[
        reporters.BuildStartEndStatusGenerator(
            start_formatter=reporters.MessageFormatter(subject="{{ status_detected }}"),
            end_formatter=reporters.MessageFormatter(subject="{{ status_detected }}"))
    ])
c['services'].append(ss)

produces the build statuses below when a build stars and ends, respectively.

https://www.wenjiangs.com/wp-content/uploads/2023/07/bitbucket-status-push.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文