🇬🇧 The Planio web site is also available in English. Do you prefer to read it in English? Yes, please switch to English!
Making Bulk Changes to Issues Planio Team Chat unter Windows mit Pidgin einrichten

Repository Commit Hooks

This guide explains how to set up subversion pre- and post-commit hooks with your Planio repository. Using pre-commit webhooks, project managers can influence the commit life cycles of repositories, by for example enforcing a certain commit message format, limiting commit rights for certain portions of the subversion repository, or by enforcing other custom rules. Post-commit hooks are useful to trigger actions like CI runs, that should happen after a successful commit.

1. Setting up your commit hooks

In your project, navigate to SettingsRepositories. Find the repository you're concerned with and click Edit. This form has a new row labelled Repository hooks, where a click on Edit leads to the list of commit hooks for that repository. Please click Add in order to create a new hook.

2. Hook configuration

First of all, choose the type of hook you intend to create. Currently, the following hooks can be created:

Type Stage Description
Insert ticket subject post-commit Changes the commit message by inserting a referenced tickets' subject after the reference: #1234 => #1234 [Ticket subject]
Require valid ticket reference pre-commit Denies commits that do not mention a valid ticket reference in their commit message. Valid ticket references are of the form #1234. The referenced ticket must be visible to the committing user.
Web hook pre-commit Sends an HTTP POST request with commit information in JSON format to a user defined URL. The commit is accepted or denied based on the remote servers' response. You can define which response codes should be considered successful. If the commit is rejected, the response body will be passed to the committing user if the response has a content type of text/plain. Otherwise, a generic error message ("Commit denied by repository configuration") will be given.
Web hook post-commit Sends an HTTP POST request with commit information in JSON format to a user defined URL

You can set up multiple hooks for the same repository, and reorder them using the drag handles in the table. Hook execution stops at the first failed hook, later hooks are not executed.

3. Web hook payload

The JSON payload we POST to your configured web hook URL contains information about the project, repository, and the actual commit.

Sample payload:

{
  "project":{
    "name":"Demo",
    "identifier":"demo",
    "id":10
  },
  "hostname":"demo.planio.com",
  "repository":{
    "id":45,
    "name":"hooktest",
    "full_name":"demo.hooktest",
    "html_url":"https://demo.planio.com/projects/demo/repository/45",
    "url":"https://demo.planio.com/projects/demo/repository/45",
    "issues_url":"https://demo.planio.com/projects/demo/issues.json",
    "size":90824,
    "svn_url":"https://demo.planio.com/svn/demo.hooktest"
  },
  "before":"1",
  "size":1,
  "commits":[{
    "committer":"jk",
    "message":"test commit",
    "added":[],
    "modified":["changed/file.txt"],
    "removed":[],
    "prop_changed":[]
  }],
  "head_commit":{
    "committer":"jk",
    "message":"test commit",
    "added":[],
    "modified":["changed/file.txt"],
    "removed":[],
    "prop_changed":[]
  }
}

Elements in the project and repository structures should be self-explaining. The remaining top level elements are:

  • before - highest revision number before this commit
  • head_commit - the last (and in the case of SVN, only) commit that is contained in this payload.
  • commits - list of all commits contained in this payload (always one for SVN)
  • size - number of commits contained in the payload (for SVN this will be always 1)

For consistency reasons we decided to stick to the payload format of the post-receive web hooks which we already have in place for Git repositories - that's why there are the seemingly redundant commits list and separate head_commit elements, which are more useful in the case of Git.

For each commit, the login of the committing user, the log message as well as the list of added / removed / modified paths, as well as paths that had properties changed, are given.

Planio kostenlos 30 Tage lang testen

Ohne Kreditkarte und unverbindlich. In nur 1 Minute angemeldet.

Keine Installation Keine Anschaffungskosten

Mit Planio Arbeiten

Sehen Sie sich an, wie unsere Kunden Planio nutzen