Pull Request POST service management

Deprecated

Creation of new service integrations has been deprecated in favor of Bitbucket Cloud's webhooks, Connect integration framework, and email notifications.

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:

イベント 説明
Approve / Unapprove Fires when user sets or unsets Approve for a pull request.
コメント Fires when a user creates, edits, or deletes a pull request comment.
Create / Edit / Merge / Decline Fires when a user creates, edits, merges, or declines a pull request.

The content header of the POST has an application/json type. This services behave similarly to an HTTP publish/subscribe service. The payload is a json document.

The POST request originates from the IP addresses 131.103.20.165 and 131.103.20.166. You may need to configure your firewall to accept connections from these IP addresses.

Configure the Pull Request POST service

You can set up the POST service manually or you can write a service to automate this. You would write a service if you are integrating an application with Bitbucket. 

Manually configure from the repository administration page

  1. Go to the repository's  settings.
  2. Click Services in the left-hand navigation.
    The Services page appears.
  3. Select the Pull Request POST service from the services dropdown.
  4. Click Add service.
    A new section appears for the POST service.
  5. Enter the URL where Bitbucket should send its update messages.

  6. Choose the pull request events you are interested in by checking the corresponding box.
  7. Press Save.

Automatically configure the URL from another application

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

If you're using OAuth or passing through basic authentication, you can use the api to accomplish this as well

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"

 

Examples of POST data

When a user makes pull request's against a repository, Bitbucket POSTs to the URL you provided. The POST request body contains information about the pull request change. 

Approval
{
   "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"
        }
    }
}
Comment Created
{
   "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
    }
}
Comment Deleted
{
   "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
    }
}
Comment Updated
{
   "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
    }
}
Merged
{
    "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"
    }
}
Declined
{
  "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"
    }
}
Approve unset
 {
   "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"
   }
}
If you are having trouble, please see  Troubleshooting Bitbucket services.
最終更新日: 2017 年 2 月 7 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

お探しの情報が見つかりませんか?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.