submits to jira

This commit is contained in:
Colin Henry 2015-10-29 21:02:04 -07:00
parent 203ceb23a3
commit aba984c39f
2 changed files with 28 additions and 2 deletions

25
jira.go
View File

@ -3,13 +3,17 @@ package main
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httputil"
)
var client *http.Client
func init() {
client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
@ -21,10 +25,11 @@ func init() {
}
func submitIssue(i []string, user string, pass string, svr string, prj string) error {
issue := newIssue(i, prj)
issueJSON := toJSON(issue)
fmt.Printf("* %s :", issue.Fields.Title)
uri := fmt.Sprintf("%s/rest/api/2/issue/", svr)
req, _ := http.NewRequest("POST", uri, bytes.NewBuffer(issueJSON))
req.Header.Set("Content-Type", "application/json")
@ -34,7 +39,23 @@ func submitIssue(i []string, user string, pass string, svr string, prj string) e
return err
}
fmt.Printf(resp)
r := make(map[string]interface{})
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
err = json.Unmarshal(contents, &r)
if err != nil {
return err
}
fmt.Printf(" created as %s", r["key"])
// printResponse(resp)
return nil
}
func printResponse(resp *http.Response) {
r, _ := httputil.DumpResponse(resp, true)
fmt.Printf(string(r))
}

View File

@ -21,6 +21,11 @@ func main() {
return
}
flag.Parse()
// fmt.Printf("%v", os.Args)
// fmt.Printf(*svr)
bufrdr := bufio.NewReader(os.Stdin)
bufrdr.ReadLine()
bufrdr.ReadLine()