submits to jira
This commit is contained in:
parent
203ceb23a3
commit
aba984c39f
25
jira.go
25
jira.go
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user