« Hooks & API

Webhooks

Last Updated: March 25, 2019

Trigger immediate reindex of your repositories from remote systems via webhooks.  For more information about this topic, see About GitLab Webhooks open in new tab .

Go to  cog Administration  > Add-ons  >  Git Integration Plugin for Jira > Webhooks.

helpful tip
If using Jira 7, go to Administration  > Add-ons. Select Applications on the page tab. Under Git Integration Plugin for Jira on the sidebar, select Webhooks.

Enable/disable the webhook feature by clicking on the Enable webhook checkbox.

The Secret Key is a secure random-generated alphanumeric string at the time of the Git add-on installation.  The user can change this to a different value by generating another secret token according to your Git host.

Use this key in the form of:

<JIRA_BASE_URL>/git/webhook/reindex/<SECRET_KEY>
Assign your Jira base URL and Secret Key to the sample URL structure:
Example:
https://your.jira.com/rest/gitplugin/webhook/1.0/reindex/sdf34tGdfgGDG345g3y0045TYG23te37
fyi
All the repositories will be reindexed if the URL specified above is activated through  GET ,  POST , or  PUT  and the webhooks are enabled.
There is no support for other HTTP methods such as  DELETE  or  HEAD .

The Git Integration for Jira app supports GitHub/GitLab push event to define individual repository to index.

The webhook parses the following payload formats:

GITLAB
{
    "repository": {
    "git_ssh_url": "git@gitlab.com:testuser01/test-master.git",
    "git_http_url": "https://gitlab.com/testuser01/test-master.git"
  }
}
GITHUB Introduced v2.7.10
{
    "repository": {
    "git_url": "git://github.com/testuser01/test-repo.git",
    "ssh_url": "git@github.com:testuser01/test-repo.git",
    "clone_url": "https://github.com/testuser01/public-repo.git",
    "svn_url": "https://github.com/testuser01/public-repo"
  }
}

Creating Reindex Triggers for a Single Repository

To create a webhook that triggers the reindex of a single repository, the following requirements are required:

  1. The git_http_url matches the Repository Origin URL from the Jira git configuration page (Git > Manage repositories > Actions > Edit integration settings).
  2. The Content-Type request header is set to application/json.
  3. Use the webhook secret key from the git configuration page > Webhooks.

The webhook is a POST request with the following JSON body:

{
  "repository":
    { "git_http_url": "https://gitlab.com/bbb-dev/bbb-testrepo.git" }
}

 

 

Result:
The repository is placed in the indexing queue.

 

« Hooks & API