Bitbucket Server のサービス webhook を POST する
リポジトリ管理者はリポジトリに POST サービスを追加できます。Bitbucket Server は、指定されたサービス URL への POST を行います。
次の形式の URL を使用できます。
https://server:port/path/
ユーザーがリポジトリへのプッシュを行うと、サービスは POST を受け取ります。
The content type header of the POST has an application/json
type. The content is a JSON payload that represents the repository push.
POST サービスのセットアップ
POST サービスを手動でセットアップすることも、これを自動化するためのサービスを記述することもできます。アプリケーションを Bitbucket Server と連携させる場合、サービスを記述します。
リポジトリの設定のセットアップ
- Go to Repository Settings > Hooks
- Click Add hook
- Install the Web Post Hooks for Bitbucket Server app
- Go back to Repository Settings > Hooks
- Find Post-receive WebHooks and choose Enabled
- Add the URLs where Bitbucket Server should send update messages. You can add 1 to 5 URLs.
- Click Enable
データの POST
ユーザーがリポジトリへのプッシュを行うと、Bitbucket Server は提供された URL への POST を行います。POST リクエストの本文には、変更が行われたリポジトリの情報、最近のコミットの一覧、プッシュを行ったユーザーの名前が含まれます。
ペイロードの例
iridium-common および iridium-magma フォルダの 2 つのファイル (pom.xml) を変更する 1 つのコミットを含むプッシュの例です。
{
"repository":{
"slug":"iridium-parent",
"id":11,
"name":"iridium-parent",
"scmId":"git",
"state":"AVAILABLE",
"statusMessage":"Available",
"forkable":true,
"project":{
"key":"IR",
"id":21,
"name":"Iridium",
"public":false,
"type":"NORMAL",
"isPersonal":false
},
"public":false
},
"refChanges":[
{
"refId":"refs/heads/master",
"fromHash":"2c847c4e9c2421d038fff26ba82bc859ae6ebe20",
"toHash":"f259e9032cdeb1e28d073e8a79a1fd6f9587f233",
"type":"UPDATE"
}
],
"changesets":{
"size":1,
"limit":100,
"isLastPage":true,
"values":[
{
"fromCommit":{
"id":"2c847c4e9c2421d038fff26ba82bc859ae6ebe20",
"displayId":"2c847c4"
},
"toCommit":{
"id":"f259e9032cdeb1e28d073e8a79a1fd6f9587f233",
"displayId":"f259e90",
"author":{
"name":"jhocman",
"emailAddress":"jhocman@atlassian.com"
},
"authorTimestamp":1374663446000,
"message":"Updating poms ...",
"parents":[
{
"id":"2c847c4e9c2421d038fff26ba82bc859ae6ebe20",
"displayId":"2c847c4"
}
]
},
"changes":{
"size":2,
"limit":500,
"isLastPage":true,
"values":[
{
"contentId":"2f259b79aa7e263f5829bb6e98096e7ec976d998",
"path":{
"components":[
"iridium-common",
"pom.xml"
],
"parent":"iridium-common",
"name":"pom.xml",
"extension":"xml",
"toString":"iridium-common/pom.xml"
},
"executable":false,
"percentUnchanged":-1,
"type":"MODIFY",
"nodeType":"FILE",
"srcExecutable":false,
"link":{
"url":"/projects/IR/repos/iridium-parent/commits/f259e9032cdeb1e28d073e8a79a1fd6f9587f233#iridium-common/pom.xml",
"rel":"self"
}
},
{
"contentId":"2f259b79aa7e263f5829bb6e98096e7ec976d998",
"path":{
"components":[
"iridium-magma",
"pom.xml"
],
"parent":"iridium-magma",
"name":"pom.xml",
"extension":"xml",
"toString":"iridium-magma/pom.xml"
},
"executable":false,
"percentUnchanged":-1,
"type":"MODIFY",
"nodeType":"FILE",
"srcExecutable":false,
"link":{
"url":"/projects/IR/repos/iridium-parent/commits/f259e9032cdeb1e28d073e8a79a1fd6f9587f233#iridium-magma/pom.xml",
"rel":"self"
}
}
],
"start":0,
"filter":null
},
"link":{
"url":"/projects/IR/repos/iridium-parent/commits/f259e9032cdeb1e28d073e8a79a1fd6f9587f233#iridium-magma/pom.xml",
"rel":"self"
}
}
],
"start":0,
"filter":null
}
}
プロパティ
Webhook Plugin のシステム全体のプロパティの一部は、Bitbucket Server の構成ファイルで上書きできます。利用可能なプロパティについては「Bitbucket Server 構成プロパティ」をご確認ください。