Skip to content

Instantly share code, notes, and snippets.

View percybolmer's full-sized avatar

ProgrammingPercy percybolmer

View GitHub Profile
// 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
}
i := jira.Issue{
Fields: &jira.IssueFields{
Assignee: &jira.User{
Name: "myuser",
},
Reporter: &jira.User{
Name: "youruser",
},
Description: "Test Issue",
Type: jira.IssueType{
// 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{
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"))
// 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)
// 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)
package main
import (
"log"
"os"
"github.com/joho/godotenv"
jira "gopkg.in/andygrunwald/go-jira.v1"
)
JIRA_USER="[email protected]"
JIRA_TOKEN="api-token"
JIRA_URL="https://your-cloud-name.atlassian.com"
package main
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
var (
HelloCounter = 1
logger zerolog.Logger
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