mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-07-13 01:00:23 +02:00
examples
basicauth
create
do
ignorecerts
newclient
renderedfields
main.go
searchpages
img
mocks
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
Makefile
PULL_REQUEST_TEMPLATE.md
README.md
authentication.go
authentication_test.go
board.go
board_test.go
component.go
component_test.go
error.go
error_test.go
field.go
field_test.go
filter.go
filter_test.go
go.mod
go.sum
group.go
group_test.go
issue.go
issue_test.go
jira.go
jira_test.go
metaissue.go
metaissue_test.go
permissionscheme.go
permissionschemes_test.go
priority.go
priority_test.go
project.go
project_test.go
resolution.go
resolution_test.go
role.go
role_test.go
sprint.go
sprint_test.go
status.go
status_test.go
statuscategory.go
statuscategory_test.go
user.go
user_test.go
version.go
version_test.go
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
![]() |
package main
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
"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 Issue key: ")
|
||
|
key, _ := r.ReadString('\n')
|
||
|
key = strings.TrimSpace(key)
|
||
|
|
||
|
fmt.Print("Jira Username: ")
|
||
|
username, _ := r.ReadString('\n')
|
||
|
|
||
|
fmt.Print("Jira Password: ")
|
||
|
bytePassword, _ := terminal.ReadPassword(int(syscall.Stdin))
|
||
|
password := string(bytePassword)
|
||
|
|
||
|
var tp *http.Client
|
||
|
|
||
|
if strings.TrimSpace(username) == "" {
|
||
|
tp = nil
|
||
|
} else {
|
||
|
|
||
|
ba := jira.BasicAuthTransport{
|
||
|
Username: strings.TrimSpace(username),
|
||
|
Password: strings.TrimSpace(password),
|
||
|
}
|
||
|
tp = ba.Client()
|
||
|
}
|
||
|
|
||
|
client, err := jira.NewClient(tp, strings.TrimSpace(jiraURL))
|
||
|
if err != nil {
|
||
|
fmt.Printf("\nerror: %v\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Printf("Targetting %s for issue %s\n", strings.TrimSpace(jiraURL), key)
|
||
|
|
||
|
options := &jira.GetQueryOptions{Expand: "renderedFields"}
|
||
|
u, _, err := client.Issue.Get(key, options)
|
||
|
|
||
|
if err != nil {
|
||
|
fmt.Printf("\n==> error: %v\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Printf("RenderedFields: %+v\n", *u.RenderedFields)
|
||
|
|
||
|
for _, c := range u.RenderedFields.Comments.Comments {
|
||
|
fmt.Printf(" %+v\n", c)
|
||
|
}
|
||
|
}
|