Package jira

import "github.com/matrix-org/go-neb/services/jira"

Overview ▾

Package jira implements a command and webhook service for interacting with JIRA.

The service adds !commands and issue expansions, in addition to JIRA webhook support.


const ServiceType = "jira"

ServiceType of the JIRA Service

type Service

type Service struct {

    // The user ID to create issues as, or to create/delete webhooks as. This user
    // is also used to look up issues for expansions.
    ClientUserID string
    // A map from Matrix room ID to JIRA realms and project keys.
    Rooms map[string]struct {
        // A map of realm IDs to project keys. The realm IDs determine the JIRA
        // endpoint used.
        Realms map[string]struct {
            // A map of project keys e.g. "SYN" to config options.
            Projects map[string]struct {
                // True to expand issues with this key e.g "SYN-123" will be expanded.
                Expand bool
                // True to add a webhook to this project and send updates into the room.
                Track bool
    // contains filtered or unexported fields

Service contains the Config fields for the JIRA service.

Before you can set up a JIRA Service, you need to set up a JIRA Realm.

Example request:

    Rooms: {
        "!qmElAGdFYCHoCJuaNt:localhost": {
            Realms: {
                "jira-realm-id": {
                    Projects: {
                        "SYN": { Expand: true },
                        "BOTS": { Expand: true, Track: true }

func (*Service) Commands

func (s *Service) Commands(cli *matrix.Client) []types.Command

Commands supported:

!jira create KEY "issue title" "optional issue description"

Responds with the outcome of the issue creation request. This command requires a JIRA account to be linked to the Matrix user ID issuing the command. It also requires there to be a project with the given project key (e.g. "KEY") to exist on the linked JIRA account. If there are multiple JIRA accounts which contain the same project key, which project is chosen is undefined. If there is no JIRA account linked to the Matrix user ID, it will return a Starter Link if there is a known public project with that project key.

func (*Service) Expansions

func (s *Service) Expansions(cli *matrix.Client) []types.Expansion

Expansions expands JIRA issues represented as:


Where "KEY" is the project key and 12" is an issue number. The Service Config will be used to map the project key to a realm, and subsequently the JIRA endpoint to hit. If there are multiple projects with the same project key in the Service Config, one will be chosen arbitrarily.

func (*Service) OnReceiveWebhook

func (s *Service) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)

OnReceiveWebhook receives requests from JIRA and possibly sends requests to Matrix as a result.

func (*Service) Register

func (s *Service) Register(oldService types.Service, client *matrix.Client) error

Register ensures that the given realm IDs are valid JIRA realms and registers webhooks with those JIRA endpoints.


Name Synopsis