mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-28 08:39:03 +02:00
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
jira "github.com/interviewstreet/go-jira"
|
|
)
|
|
|
|
func main() {
|
|
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
|
|
|
|
// Running JQL query
|
|
|
|
jql := "project = Mesos and type = Bug and Status NOT IN (Resolved)"
|
|
fmt.Printf("Usecase: Running a JQL query '%s'\n", jql)
|
|
issues, resp, err := jiraClient.Issue.Search(jql, nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
outputResponse(issues, resp)
|
|
|
|
fmt.Println("")
|
|
fmt.Println("")
|
|
|
|
// Running an empty JQL query to get all tickets
|
|
jql = ""
|
|
fmt.Printf("Usecase: Running an empty JQL query to get all tickets\n")
|
|
issues, resp, err = jiraClient.Issue.Search(jql, nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
outputResponse(issues, resp)
|
|
}
|
|
|
|
func outputResponse(issues []jira.Issue, resp *jira.Response) {
|
|
fmt.Printf("Call to %s\n", resp.Request.URL)
|
|
fmt.Printf("Response Code: %d\n", resp.StatusCode)
|
|
fmt.Println("==================================")
|
|
for _, i := range issues {
|
|
fmt.Printf("%s (%s/%s): %+v\n", i.Key, i.Fields.Type.Name, i.Fields.Priority.Name, i.Fields.Summary)
|
|
}
|
|
}
|