Bitbucket Cloud のブローカー/サービスを記述する

非推奨

Bitbucket Cloud の webhook、接続統合フレームワーク、およびメール通知により、新しいサービス連携の作成は非推奨となりました。

新しいブローカーの制限

現在、新しいブローカーの許可は行われていません。POST サービスの使用について、後述の情報をご参照ください。

Bitbucket Cloud  integrates with external services through a set of brokers that run in response to certain events.  Brokers are Python scripts that receive information about an event and then take one or more actions. For example, there is a Bamboo broker for integrating with Bamboo.   The Bitbucket team developed many of our brokers. Third-party vendors also developed several brokers.

Using the POST service to integrate your application with Bitbucket Cloud

ほとんどのサードパーティ製アプリケーションは REST API を公開しています。これには Jenkins などがあります。サードパーティの API を使用することで、Bitbucket の POST サービスを使用して対象のサービスにパラメータを渡すことができます。Bitbucket の POST サービスは、サードパーティ製の Web アプリケーションに、アプリの API を経由してペイロードを渡します。ペイロードの受信や転送はサードパーティ製アプリケーション側が行います。

Bitbucket リポジトリに POST サービスを追加するには、次の手順を実行します。

  1. 対象の POST 呼び出しに対応するサードパーティの REST API を確認します。
    たとえば、URL に次のようにユーザー トークンを含めることができます。
    http://myservice/broker?token=bfkbd
  2. リポジトリ 設定に移動します。
  3. 左側のナビゲーションから [サービス] を選択します。
    [サービス] ページが表示されます。 
  4. サービスのドロップダウンから [POST] を選択します。
  5. [サービスの追加] を押します。
  6. サードパーティ サービスの URL を入力します。
  7. [保存] を押します。
    アクティブなサービスの一覧に新しい POST サービスが表示されます。 

ユーザーが次回リポジトリへのプッシュを行うと、POST サービスが実行され、データのペイロードがご利用のサービスに送信されます。サービスはペイロードを受け取り、Bitbucket の REST API を使用してデータを適切に処理します。たとえば、アプリケーションは OAuth を使用する特定のリソースやその他の情報のために Bitbucket へのコールバックを行うことができます。

サービスに送信されるペイロードについて

プッシュのペイロードは、リポジトリ、コミット、およびサービス固有の値を含む、形式の統一されたディクショナリです。 

ユーザーがリポジトリへのプッシュを行うと、Bitbucket は提供された URL への POST を行います。POST リクエストのボディには、変更箇所などのリポジトリ情報、最近のコミットの一覧、プッシュを行ったユーザーが含まれます。 

Mercurial
{
    "canon_url": "https://bitbucket.org", 
    "commits": [
        {
            "author": "marcus", 
            "branch": "featureA", 
            "files": [
                {
                    "file": "somefile.py", 
                    "type": "modified"
                }
            ], 
            "message": "Added some featureA things", 
            "node": "d14d26a93fd2", 
            "parents": [
                "1b458191f31a"
            ], 
            "raw_author": "Marcus Bertrand <marcus@somedomain.com>", 
            "raw_node": "d14d26a93fd28d3166fa81c0cd3b6f339bb95bfe", 
            "revision": 3, 
            "size": -1, 
            "timestamp": "2012-05-30 06:07:03", 
            "utctimestamp": "2012-05-30 04:07:03+00:00"
        }
    ], 
    "repository": {
        "absolute_url": "/marcus/project-x/", 
        "fork": false, 
        "is_private": true, 
        "name": "Project X", 
        "owner": "marcus", 
        "scm": "hg", 
        "slug": "project-x", 
        "website": ""
    }, 
    "user": "marcus"
}
Git
{
    "canon_url": "https://bitbucket.org", 
    "commits": [
        {
            "author": "marcus", 
            "branch": "master", 
            "files": [
                {
                    "file": "somefile.py", 
                    "type": "modified"
                }
            ], 
            "message": "Added some more things to somefile.py\n", 
            "node": "620ade18607a", 
            "parents": [
                "702c70160afc"
            ], 
            "raw_author": "Marcus Bertrand <marcus@somedomain.com>", 
            "raw_node": "620ade18607ac42d872b568bb92acaa9a28620e9", 
            "revision": null, 
            "size": -1, 
            "timestamp": "2012-05-30 05:58:56", 
            "utctimestamp": "2012-05-30 03:58:56+00:00"
        }
    ], 
    "repository": {
        "absolute_url": "/marcus/project-x/", 
        "fork": false, 
        "is_private": true, 
        "name": "Project X", 
        "owner": "marcus", 
        "scm": "git", 
        "slug": "project-x", 
        "website": "https://atlassian.com/"
    }, 
    "user": "marcus"
}

最終更新日 2020 年 6 月 23 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.