This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// Load the .env file | |
godotenv.Load(".env") | |
// Create a BasicAuth Transport object | |
tp := jira.BasicAuthTransport{ | |
Username: os.Getenv("JIRA_USER"), | |
Password: os.Getenv("JIRA_TOKEN"), | |
} | |
// Create a new Jira Client | |
client, err := jira.NewClient(tp.Client(), os.Getenv("JIRA_URL")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getIssues will query Jira API using the provided JQL string | |
func getIssues(client *jira.Client, jql string) ([]jira.Issue, error) { | |
// lastIssue is the index of the last issue returned | |
lastIssue := 0 | |
// Make a loop through amount of issues | |
var result []jira.Issue | |
for { | |
// Add a Search option which accepts maximum amount (1000) | |
opt := &jira.SearchOptions{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i := jira.Issue{ | |
Fields: &jira.IssueFields{ | |
Assignee: &jira.User{ | |
Name: "myuser", | |
}, | |
Reporter: &jira.User{ | |
Name: "youruser", | |
}, | |
Description: "Test Issue", | |
Type: jira.IssueType{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getIssueTransition will grab the available transitions for a issue | |
func getIssueTransition(client *jira.Client, issue jira.Issue, status string) (jira.Transition, error) { | |
transitions, _, err := client.Issue.GetTransitions(issue.Key) | |
if err != nil { | |
return jira.Transition{}, err | |
} | |
for _, t := range transitions { | |
if t.Name == status { | |
return t, nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// Load the .env file | |
godotenv.Load(".env") | |
// Create a BasicAuth Transport object | |
tp := jira.BasicAuthTransport{ | |
Username: os.Getenv("JIRA_USER"), | |
Password: os.Getenv("JIRA_TOKEN"), | |
} | |
// Create a new Jira Client | |
client, err := jira.NewClient(tp.Client(), os.Getenv("JIRA_URL")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// transitionIssue will move a issue into the new transition | |
func transitionIssue(client *jira.Client, issue jira.Issue, transition jira.Transition) error { | |
_, err := client.Issue.DoTransition(issue.ID, transition.ID) | |
return err | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2021/08/04 21:19:40 Hello | |
{"level":"debug", "time":"2021-08-04T21:19:40+02:00","message":"Hello"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"info","service":"my-service","Some integer":10,"time":"2021-08-04T21:30:56+02:00","message":"Hello"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"info","service":"my-service","Some integer":10,"time":"2021-08-04T21:37:09+02:00","message":"Hello"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"info","service":"my-service","node":"localhost","count":1,"time":"2021-08-04T21:47:34+02:00","message":"Hello"} | |
{"level":"info","service":"my-service","node":"localhost","count":2,"time":"2021-08-04T21:47:34+02:00","message":"Hello"} |