# Jiraport

## Overview

Jiraport is a Jira issue notifier and more

## Prerequisites

* [An AWS account](https://aws.amazon.com/)
* [Golang](https://golang.org/doc/install)
* [Docker](https://docs.docker.com/install)
* [Node.js](https://nodejs.org/en/download/)
* [AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)
* [SAM CLI](https://aws.amazon.com/serverless/sam/)
* [jq](https://stedolan.github.io/jq/) (optional)

## Usage

### Run Locally

:warning: Make sure to install all the [Prerequisites](#prerequisites), and ensure that the Docker VM is running.

1. start jiraport-apiserver
```sh
# please use the real profile name to instead of profileName
AWS_PROFILE=profileName make run-api
```

apiserver will listen on 127.0.0.1:3000

2. open another tab, then start jiraport-resolver
```sh
# please use the real profile name to instead of profileName
AWS_PROFILE=profileName make run-resolver
```

3. You can now consume the API.

```sh
curl localhost:3000/version
```

### Test API

<!-- JIRAlert expects a JSON object from Alertmanager. The format of this JSON is described in the [Alertmanager documentation](https://prometheus.io/docs/alerting/configuration/#<webhook_config>) or, alternatively, in the [Alertmanager GoDoc](https://godoc.org/github.com/prometheus/alertmanager/template#Data). -->

To quickly test if Jiraport is working you can run:

```bash
curl -X POST http://localhost:3000/jira/webhook/test \
-H "Content-type: application/json" \
--data-raw '{
  "issue_event_type_name": "issue_created",
  "webhookEvent": "jira:issue_created",
  "user": {
    "name": "jiraport-test@pingcap.com",
    "emailAddress": "jiraport-test@pingcap.com",
    "displayName": "Jiraport Test",
    "active": true
  },
  "issue": {
    "key": "O11YDEV-123456",
    "self": "https://jira.tidbcloud.com/rest/api/2/issue/2416893",
    "fields": {
      "Creator": {
        "active": true,
        "displayName": "Jiraport Test",
        "emailAddress": "jiraport-test@pingcap.com",
        "name": "jiraport-test@pingcap.com"
      },
      "components": [{"name": "resilience"}],
      "created": "2024-08-12T00:01:46.377+0000",
      "customfield_10700": "raw alert content",
      "description": "description test",
      "issuetype": {"name": "Task"},
      "priority": {"name": "Major"},
      "project": {
        "key": "O11YDEV",
        "name": "O11YDEV"
      },
      "reporter": {
        "active": true,
        "displayName": "Jiraport Test",
        "emailAddress": "jiraport-test@pingcap.com",
        "name": "jiraport-test@pingcap.com"
      },
      "status": {"name": "Created"},
      "summary": "TEST Alert"
    }
  },
  "changelog": {
    "id": "",
    "items": null
  },
  "timestamp": 1718150506747
}'
```
