-
Notifications
You must be signed in to change notification settings - Fork 1
/
jira.go
36 lines (30 loc) · 839 Bytes
/
jira.go
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
package main
import (
"fmt"
"net/http"
"strings"
"time"
"github.com/andygrunwald/go-jira"
)
var (
client = &http.Client{Timeout: 10 * time.Second}
)
func getTicket(key string, creds credentials) (*jira.Issue, error) {
jiraClient, err := jira.NewClient(client, creds.Base)
if err != nil {
return nil, err
}
jiraClient.Authentication.SetBasicAuth(creds.Username, creds.Password)
issue, _, err := jiraClient.Issue.Get(key, nil)
return issue, err
}
func getTickets(keys []string, creds credentials) ([]jira.Issue, error) {
jiraClient, err := jira.NewClient(client, creds.Base)
if err != nil {
return nil, err
}
jiraClient.Authentication.SetBasicAuth(creds.Username, creds.Password)
jql := fmt.Sprintf("key in (%s)", strings.Join(keys, ","))
issues, _, err := jiraClient.Issue.Search(jql, nil)
return issues, err
}