summaryrefslogtreecommitdiffstats
path: root/scripts/jira/jira-bug-closer/README.md
blob: 8ddd271d6ec25a888ace45e80fd264524308f709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# JIRA bot to close issues

Listen to gerrit events and close corresponding JIRA tasks when there is a "Fixes:" footer in the commit message.

## Prerequisites and building

You need to have [pipenv](https://pipenv.readthedocs.io/en/latest/) installed.
Run `make` to install dependencies.

## Connecting to a JIRA account using OAuth

* Generate a private/public rsa certificate pair (`jiracloser.pem`, `jiracloser.pub`) in the root directory (next to this readme file).
  * See for example https://www.madboa.com/geek/openssl/#key-rsa

* Log in to JIRA as admin.
* Find "Integrations" -> "Application Links"
  * Enter a random URL (e.g. https://www.qt.io) and click "Create new link"
  * Fill out the fields, it does not really matter:
    * Name: Gerrit Issue Bot
    * Type: Generic
    * Service Provider Name: Qt JIRA bot (anything goes)
    * Consumer key: jira-gerrit-bot-oauth-consumer
    * Shared Secret: 8aG2#dwV24$e9J43@s8b  # this is actually unused, put some random garbage here to make sure
    * Request Token URL: https://www.qt.io
    * Access token URL: https://www.qt.io
    * Authorize URL: https://www.qt.io
    * Create incoming link: yes
  * Next page (this is important, can be edited later under incoming authentication)
    * Consumer key: jira-gerrit-oauth
    * Consumer Name: Gerrit Issue Closer
    * Public Key: content of `jiracloser.pub`
  * You can delete the outgoing auth after this excercise

* Log in to JIRA with the bot user.
* In a terminal run: `make oauth`
* The script puts out a URL, which must be *opened as the bot user*
* Click Allow
* Press enter in the terminal
* Copy the `oauth_token` and `oauth_token_secret` into config.ini.

## Running the bot

`make run`

## Running tests

Run `make test` which runs a style check, type checking and the automated tests.
Please make sure that all of them pass before contributing.

It's also possible to generate coverage information (`make coverage` will open a a browser).