mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-30 08:47:11 +02:00
64 lines
1.1 KiB
Go
64 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"syscall"
|
|
|
|
jira "github.com/andygrunwald/go-jira"
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
)
|
|
|
|
func main() {
|
|
r := bufio.NewReader(os.Stdin)
|
|
|
|
fmt.Print("Jira URL: ")
|
|
jiraURL, _ := r.ReadString('\n')
|
|
|
|
fmt.Print("Jira Username: ")
|
|
username, _ := r.ReadString('\n')
|
|
|
|
fmt.Print("Jira Password: ")
|
|
bytePassword, _ := terminal.ReadPassword(int(syscall.Stdin))
|
|
password := string(bytePassword)
|
|
|
|
tp := jira.BasicAuthTransport{
|
|
Username: strings.TrimSpace(username),
|
|
Password: strings.TrimSpace(password),
|
|
}
|
|
|
|
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL))
|
|
if err != nil {
|
|
fmt.Printf("\nerror: %v\n", err)
|
|
return
|
|
}
|
|
|
|
i := jira.Issue{
|
|
Fields: &jira.IssueFields{
|
|
Assignee: &jira.User{
|
|
Name: "myuser",
|
|
},
|
|
Reporter: &jira.User{
|
|
Name: "youruser",
|
|
},
|
|
Description: "Test Issue",
|
|
Type: jira.IssueType{
|
|
Name: "Bug",
|
|
},
|
|
Project: jira.Project{
|
|
Key: "PROJ1",
|
|
},
|
|
Summary: "Just a demo issue",
|
|
},
|
|
}
|
|
|
|
issue, _, err := client.Issue.Create(&i)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
|
|
}
|