プルリクエスト POST サービスの管理

robotsnoindex

非推奨

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

Repository administrators can add a Pull Request POST service to a repository. Bitbucket Cloud POSTs pull request event data to a service URL you specify.  You specify a URL in the format:

https://user:password@server:port/path/

Bitbucket Cloud  supports HTTPS and basic authentication.  When configuring the pull request POST service, you can choose to get event data about the following:

イベント説明
承認 / 未承認ユーザーがプル リクエストで承認をセットまたは解除したときにトリガーされます。
コメントユーザーがプル リクエスト コメントを作成、編集、または削除したときにトリガーされます。
作成 / 編集 / マージ / 却下ユーザーがプル リクエストを作成、編集、マージ、または却下したときにトリガーされます。

POST のコンテンツ ヘッダーには application/json タイプが含まれます。このサービスは、HTTP の公開 / サブスクライブ サービスと似た挙動を持ちます。ペイロードは json ドキュメントです。

POST リクエストは、131.103.20.165 と 131.103.20.166 の IP アドレスから送信されます。これらの IP アドレスからの接続を許可するようにファイアウォールを構成する必要がある場合があります。

Pull Request POST サービスを構成する

POST サービスを手動でセットアップすることも、自動化するためのサービスを記述することもできます。アプリケーションを Bitbucket と連携させる場合、サービスを記述します。 

リポジトリ管理画面からの手動構成

  1. リポジトリの 設定に移動します。
  2. 左側のナビゲーションにある [サービス] をクリックします。
    サービス ページが表示されます。
  3. サービスのドロップダウン リストから [Pull Request POST] サービスを選択します。
  4. [サービスの追加] をクリックします。
    [POST] サービスに新しいセクションが表示されます。
  5. Bitbucket の更新メッセージの送信先の URL を入力します。

  6. 対象のプル リクエスト イベントのチェックボックスを選択します。
  7. [保存] をクリックします。

他のアプリケーションから URL を自動的に構成

If you are integrating with Bitbucket Cloud and looking for an easy way to add the service for your users, there are two methods you can use to automate this.  You can send the user to a URL structured in the following way:

https://bitbucket.org/{username}/{repo_slug}/admin/services?service=Pull%20Request%20POST&url={URL}&create%2Fedit%2Fmerge%2Fdecline=on&comments=on&approve%2Funapprove=on

OAuth を使用しているか、BASIC 認証を利用している場合、API を使用して同じ内容を実現できます。

https://api.bitbucket.org/1.0/repositories/{username}/{repo_slug}/services/ -data "type=POST&URL=https%3A%2F%2Fwww.test.comcreate%2Fedit%2Fmerge%2Fdecline=on&comments=on&approve%2Funapprove=on"


POST データの例

ユーザーがリポジトリへのプル リクエストを行うと、Bitbucket は提供された URL への POST を行います。POST リクエストのボディには、プル リクエストの変更についての情報が含まれます。 

承認
{
   "pullrequest_approve":{
        "date": "2013-11-05T02:03:03.551896+00:00",
        "user": {
            "display_name": "Erik van Zijst",
            "links": {
                "avatar": {
                    "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
                },
                "self": {
                    "href": "http://api.bitbucket.org/2.0/users/evzijst"
                }
            },
            "username": "evzijst"
        }
    }
}
コメントの作成
{
   "pullrequest_comment_created":{
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/comments/13"
        }, 
        "code": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/diff/evzijst/bitbucket2:325625d47b0a..82d48819e5f7?path=apps%2Faccount%2Ftemplatetags%2Faccount.py"
        }, 
        "html": {
          "href": "https://bitbucket.org/evzijst/bitbucket2/pull-request/24/_/diff#comment-13"
        }
      }, 
      "content": {
        "raw": "Inline comment.", 
        "markup": "markdown", 
        "html": "<p>Inline comment.</p>"
      }, 
      "created_on": "2013-11-07T05:23:36.013764+00:00", 
      "user": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      }, 
      "updated_on": "2013-11-07T05:23:36.015070+00:00", 
      "inline": {
        "to": 237, 
        "from": null, 
        "path": "apps/account/templatetags/account.py"
      }, 
      "id": 13
    }
}
コメントの削除
{
   "pullrequest_comment_deleted":{
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/comments/13"
        }, 
        "code": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/diff/evzijst/bitbucket2:325625d47b0a..82d48819e5f7?path=apps%2Faccount%2Ftemplatetags%2Faccount.py"
        }, 
        "html": {
          "href": "https://bitbucket.org/evzijst/bitbucket2/pull-request/24/_/diff#comment-13"
        }
      }, 
      "content": {
        "raw": "Inline comment.", 
        "markup": "markdown", 
        "html": "<p>Inline comment.</p>"
      }, 
      "created_on": "2013-11-07T05:23:36.013764+00:00", 
      "user": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      }, 
      "updated_on": "2013-11-07T05:23:36.015070+00:00", 
      "inline": {
        "to": 237, 
        "from": null, 
        "path": "apps/account/templatetags/account.py"
      }, 
      "id": 13
    }
}
コメントの更新
{
   "pullrequest_comment_updated":{
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/comments/13"
        }, 
        "code": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/diff/evzijst/bitbucket2:325625d47b0a..82d48819e5f7?path=apps%2Faccount%2Ftemplatetags%2Faccount.py"
        }, 
        "html": {
          "href": "https://bitbucket.org/evzijst/bitbucket2/pull-request/24/_/diff#comment-13"
        }
      }, 
      "content": {
        "raw": "Inline comment.", 
        "markup": "markdown", 
        "html": "<p>Inline comment.</p>"
      }, 
      "created_on": "2013-11-07T05:23:36.013764+00:00", 
      "user": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      }, 
      "updated_on": "2013-11-07T05:23:36.015070+00:00", 
      "inline": {
        "to": 237, 
        "from": null, 
        "path": "apps/account/templatetags/account.py"
      }, 
      "id": 13
    }
}
作成日
{
  "pullrequest_created":{
      "description": "Added description", 
      "links": {
        "decline": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/decline"
        }, 
        "commits": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/commits"
        }, 
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24"
        }, 
        "comments": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/comments"
        }, 
        "patch": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/patch"
        }, 
        "merge": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/merge"
        }, 
        "html": {
          "href": "https://bitbucket.org/evzijst/bitbucket2/pull-request/24"
        }, 
        "activity": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/activity"
        }, 
        "diff": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/diff"
        }, 
        "approve": {
          "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/pullrequests/24/approve"
        }
      }, 
      "title": "PR title", 
      "close_source_branch": true, 
      "reviewers": [
        {
          "username": "nvenegas", 
          "display_name": "Nicolas Venegas", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/users/nvenegas"
            }, 
            "avatar": {
              "href": "http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=&s=32"
            }
          }
        }
      ], 
      "destination": {
        "commit": {
          "hash": "82d48819e5f7", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/82d48819e5f7"
            }
          }
        }, 
        "branch": {
          "name": "staging"
        }, 
        "repository": {
          "full_name": "evzijst/bitbucket2", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
            }, 
            "avatar": {
              "href": "https://bitbucket.org/m/bf1e763db20f/img/language-avatars/default_16.png"
            }
          }, 
          "name": "bitbucket2"
        }
      }, 
      "state": "OPEN", 
      "id": 24, 
      "source": {
        "commit": {
          "hash": "325625d47b0a", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/325625d47b0a"
            }
          }
        }, 
        "branch": {
          "name": "mfrauenholtz/inbox"
        }, 
        "repository": {
          "full_name": "evzijst/bitbucket2", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
            }, 
            "avatar": {
              "href": "http://bitbucket.org/m/bf1e763db20f/img/language-avatars/default_16.png"
            }
          }, 
          "name": "bitbucket2"
        }
      }, 
      "reason": "", 
      "author": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      }, 
      "created_on": "2013-11-04T23:41:48.941334+00:00", 
      "participants": [
        {
          "role": "REVIEWER", 
          "user": {
            "username": "nvenegas", 
            "display_name": "Nicolas Venegas", 
            "links": {
              "self": {
                "href": "https://api.bitbucket.org/2.0/users/nvenegas"
              }, 
              "avatar": {
                "href": "http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=&s=32"
              }
            }
          }, 
          "approved": false
        }, 
        {
          "role": "PARTICIPANT", 
          "user": {
            "username": "evzijst", 
            "display_name": "Erik van Zijst", 
            "links": {
              "self": {
                "href": "https://api.bitbucket.org/2.0/users/evzijst"
              }, 
              "avatar": {
                "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
              }
            }
          }, 
          "approved": true
        }
      ], 
      "updated_on": "2013-11-08T18:55:37.272783+00:00", 
      "merge_commit": null, 
      "closed_by": null
    }
}
マージ
{
    "pullrequest_merged": {
        "description": "",
        "title": "Inbox changes",
        "close_source_branch": true,
        "destination": {
            "commit": {
                "hash": "82d48819e5f7",
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/82d48819e5f7"
                    }
                }
            },
            "repository": {
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
                    },
                    "avatar": {
                        "href": "https://bitbucket.org/m/d864f6bcaa94/img/language-avatars/default_16.png"
                    }
                },
                "full_name": "evzijst/bitbucket2",
                "name": "bitbucket2"
            },
            "branch": {
                "name": "staging"
            }
        },
        "reason": "",
        "source": {
            "commit": {
                "hash": "325625d47b0a",
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/325625d47b0a"
                    }
                }
            },
            "repository": {
                "links": {
                    "self": {
                        "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
                    },
                    "avatar": {
                        "href": "https://bitbucket.org/m/d864f6bcaa94/img/language-avatars/default_16.png"
                    }
                },
                "full_name": "evzijst/bitbucket2",
                "name": "bitbucket2"
            },
            "branch": {
                "name": "mfrauenholtz/inbox"
            }
        },
        "state": "MERGED",
        "author": {
            "username": "evzijst",
            "display_name": "Erik van Zijst",
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/users/evzijst"
                },
                "avatar": {
                    "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
                }
            }
        },
        "date": "2013-11-08T19:49:12.233187+00:00"
    }
}
却下
{
  "pullrequest_declined": {
      "description": "Added description", 
      "title": "PR title", 
      "close_source_branch": false, 
      "destination": {
        "commit": {
          "hash": "82d48819e5f7", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/82d48819e5f7"
            }
          }
        }, 
        "branch": {
          "name": "staging"
        }, 
        "repository": {
          "full_name": "evzijst/bitbucket2", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
            }, 
            "avatar": {
              "href": "https://api.bitbucket.org/m/bf1e763db20f/img/language-avatars/default_16.png"
            }
          }, 
          "name": "bitbucket2"
        }
      }, 
      "state": "DECLINED", 
      "source": {
        "commit": {
          "hash": "325625d47b0a", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2/commit/325625d47b0a"
            }
          }
        }, 
        "branch": {
          "name": "mfrauenholtz/inbox"
        }, 
        "repository": {
          "full_name": "evzijst/bitbucket2", 
          "links": {
            "self": {
              "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket2"
            }, 
            "avatar": {
              "href": "https://api.bitbucket.org/m/bf1e763db20f/img/language-avatars/default_16.png"
            }
          }, 
          "name": "bitbucket2"
        }
      }, 
      "reason": "Weak sauce.", 
      "author": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      }, 
      "date": "2013-11-04T23:41:48.941334+00:00"
    }
}
承認状態の解除
 {
   "pullrequest_unapprove":{
      "date":"2013-07-19 21:34:33+00:00",
      "user":{
         "username":"detkin",
         "display_name":"Dylan Etkin",
         "links":[
            {
               "href":"https://api.bitbucket.org/1.0/users/detkin",
               "rel":"self"
            },
            {
               "href":"https://bitbucket.org/detkin",
               "rel":"html"
            }
         ]
      }
   }
}
更新日
 {
   "pullrequest_updated":{
      "state":"OPEN",
      "description":"README.md made even better",
      "title":"README.md made even better",
      "destination":{
         "commit":{
            "hash":"927fd129ad69",
            "links":[
               {
                  "href":"https://api.bitbucket.org/2.0/repositories/detkin/test/commit/927fd129ad69",
                  "rel":"self"
               }
            ]
         },
         "repository":{
            "links":[
               {
                  "href":"https://api.bitbucket.org/1.0/repositories/detkin/test",
                  "rel":"self"
               },
               {
                  "href":"https://bitbucket.org/detkin/test",
                  "rel":"html"
               },
               {
                  "href":"https://bitbucket.org/detkin/test",
                  "type":"https",
                  "rel":"clone"
               },
               {
                  "href":"ssh://hg@bitbucket.org/detkin/test",
                  "type":"ssh",
                  "rel":"clone"
               }
            ],
            "full_name":"detkin/test"
         },
         "branch":{
            "name":"default"
         }
      },
      "source":{
         "commit":{
            "hash":"6ddd631f33de",
            "links":[
               {
                  "href":"https://api.bitbucket.org/2.0/repositories/detkin/test/commit/6ddd631f33de",
                  "rel":"self"
               }
            ]
         },
         "repository":{
            "links":[
               {
                  "href":"https://api.bitbucket.org/1.0/repositories/detkin/test",
                  "rel":"self"
               },
               {
                  "href":"https://bitbucket.org/detkin/test",
                  "rel":"html"
               },
               {
                  "href":"https://bitbucket.org/detkin/test",
                  "type":"https",
                  "rel":"clone"
               },
               {
                  "href":"ssh://hg@bitbucket.org/detkin/test",
                  "type":"ssh",
                  "rel":"clone"
               }
            ],
            "full_name":"detkin/test"
         },
         "branch":{
            "name":"detkin/readmemd-made-even-better"
         }
      },
      "reason":"",
      "author": {
        "username": "evzijst", 
        "display_name": "Erik van Zijst", 
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/users/evzijst"
          }, 
          "avatar": {
            "href": "https://bitbucket-staging-assetroot.s3.amazonaws.com/c/photos/2013/Oct/28/evzijst-avatar-3454044670-3_avatar.png"
          }
        }
      },
      "date":"2013-07-19 21:04:15+00:00"
   }
}
問題がある場合、「Bitbucket サービスのトラブルシューティング」をご覧ください。
最終更新日 2020 年 6 月 24 日

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

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