POST サービスの管理
Repository administrators can add a POST service to a repository. Bitbucket Cloud POSTs to a service URL you specify. Bitbucket supports HTTPS and basic authentication. For example, you can use a URL in the format:
https://user:password@server:port/path/
POST リクエストは、ファイアウォール情報のページで案内されている IP アドレスから送信されます。これらの IP アドレスからの接続を許可するようにファイアウォールを構成する必要がある場合があります。
ユーザーがリポジトリへのプッシュを行うと、サービスは POST を受け取ります。POST のコンテンツ ヘッダーには application/x-www-form-urlencoded
タイプが含まれます。このサービスは、HTTP の公開 / サブスクライブ サービスと似た挙動を持ちます。ペイロードでは、実際のペイロードの先頭に payload=
が付与されます。ペイロードは、URL エンコードされたコンテンツです。
POST サービスのセットアップ
POST サービスを手動でセットアップすることも、アプリケーションからのサービス作成を自動化することもできます。
リポジトリ管理画面からの手動操作
- リポジトリの 設定に移動します。
- 左側のナビゲーションにある [サービス] をクリックします。
サービス ページが表示されます。 - サービスのドロップダウン リストから [POST] を選択します。
- [サービスの追加] をクリックします。
[POST] サービスに新しいセクションが表示されます。 Bitbucket の更新メッセージの送信先の 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/hooks?service=POST&url={your custom url}
OAuth を使用しているか、BASIC 認証を利用している場合、API を使用して同じ内容を実現できます。
https://api.bitbucket.org/1.0/repositories/{username}/{repo_slug}/services/ -data "type=POST&URL=https%3A%2F%2Fwww.test.com"
データの POST
例
{
"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"
}
{
"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"
}