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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var client *http.Client
|
var client *http.Client
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
client = &http.Client{
|
client = &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
@ -21,10 +25,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func submitIssue(i []string, user string, pass string, svr string, prj string) error {
|
func submitIssue(i []string, user string, pass string, svr string, prj string) error {
|
||||||
|
|
||||||
issue := newIssue(i, prj)
|
issue := newIssue(i, prj)
|
||||||
issueJSON := toJSON(issue)
|
issueJSON := toJSON(issue)
|
||||||
|
|
||||||
|
fmt.Printf("* %s :", issue.Fields.Title)
|
||||||
|
|
||||||
uri := fmt.Sprintf("%s/rest/api/2/issue/", svr)
|
uri := fmt.Sprintf("%s/rest/api/2/issue/", svr)
|
||||||
req, _ := http.NewRequest("POST", uri, bytes.NewBuffer(issueJSON))
|
req, _ := http.NewRequest("POST", uri, bytes.NewBuffer(issueJSON))
|
||||||
req.Header.Set("Content-Type", "application/json")
|
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
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printResponse(resp *http.Response) {
|
||||||
|
r, _ := httputil.DumpResponse(resp, true)
|
||||||
|
fmt.Printf(string(r))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user