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
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
// 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
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) { | |
issues, _, err := client.Issue.Search(jql, nil) | |
if err != nil { | |
panic(err) | |
} | |
for _, i := range issues { | |
fmt.Printf("%s (%s/%s): %+v -> %s\n", i.Key, i.Fields.Type.Name, i.Fields.Priority.Name, i.Fields.Summary, i.Fields.Status.Name) | |
fmt.Printf("Assignee : %v\n", i.Fields.Assignee.DisplayName) |
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
// getProjects is a function that lists all projects | |
func getProjects(client *jira.Client) { | |
// use the Project domain to list all projects | |
projectList, _, err := client.Project.GetList() | |
if err != nil { | |
log.Fatal(err) | |
} | |
// Range over the projects and print the key and name | |
for _, project := range *projectList { | |
fmt.Printf("%s: %s\n", project.Key, project.Name) |
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
package main | |
import ( | |
"log" | |
"os" | |
"github.com/joho/godotenv" | |
jira "gopkg.in/andygrunwald/go-jira.v1" | |
) |
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
JIRA_USER="[email protected]" | |
JIRA_TOKEN="api-token" | |
JIRA_URL="https://your-cloud-name.atlassian.com" |
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
package main | |
import ( | |
"github.com/rs/zerolog" | |
"github.com/rs/zerolog/log" | |
) | |
var ( | |
HelloCounter = 1 | |
logger zerolog.Logger |
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
package main | |
import ( | |
"github.com/rs/zerolog" | |
"github.com/rs/zerolog/log" | |
) | |
func main() { | |
// Apply zerolog global level, this will stop zerolog from logging any debug messages |