1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00
Go to file
2016-03-26 23:37:57 +01:00
img Added project logo 2015-09-03 12:48:16 +02:00
.gitignore Added gitignore 2015-08-20 17:04:59 +02:00
.travis.yml Added Golang 1.4 and 1.5 to travisci 2016-03-26 18:32:54 +01:00
authentication_test.go FIxed test names in ath tests 2016-03-26 23:37:57 +01:00
authentication.go Added the first go code 2015-09-03 12:25:21 +02:00
errors_test.go Fix #1: Add some unit tests 2016-03-26 21:23:12 +01:00
errors.go Fixed golint: warning: if block ends with a return statement, so drop this else and outdent its block (golint) 2016-03-26 21:27:38 +01:00
issue.go FIxed test names in ath tests 2016-03-26 23:37:57 +01:00
jira_test.go Added tests for authentication 2016-03-26 22:58:28 +01:00
jira.go Fixed typo 2016-03-26 21:24:23 +01:00
LICENSE Initial commit 2015-08-20 17:02:46 +02:00
README.md Added newline to README 2016-03-26 21:43:30 +01:00

go-jira

GoDoc Build Status Go Report Card Coverage Status

Go client library for Atlassian JIRA.

Go client library for Atlassian JIRA

The code structure of this package was inspired by google/go-github.

Features

  • Authentication (HTTP Basic, OAuth, Session Cookie)
  • Create and receive issues
  • Call every (not implemented) API endpoint of the JIRA

Attention: This package is not JIRA API complete (yet), but you can call every API endpoint you want. See "Call a not implemented API endpoint" how to do this. For all possible API endpoints have a look at latest JIRA REST API documentation.

Installation

It is go gettable

$ go get github.com/andygrunwald/go-jira

(optional) to run unit / example tests:

$ cd $GOPATH/src/github.com/andygrunwald/go-jira
$ go test -v

API

Please have a look at the GoDoc documentation for a detailed API description.

The latest JIRA REST API documentation was the base document for this package.

Examples

Further a few examples how the API can be used. A few more examples are available in the GoDoc examples section.

Get a single issue

Lets retrieve MESOS-3325 from the Apache Mesos project.

package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
	issue, _, _ := jiraClient.Issue.Get("MESOS-3325")

	fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
	fmt.Printf("Type: %s\n", issue.Fields.Type.Name)
	fmt.Printf("Priority: %s\n", issue.Fields.Priority.Name)

	// MESOS-3325: Running mesos-slave@0.23 in a container causes slave to be lost after a restart
	// Type: Bug
	// Priority: Critical
}
package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, err := jira.NewClient(nil, "https://your.jira-instance.com/")
	if err != nil {
		panic(err)
	}

	res, err := jiraClient.Authentication.AcquireSessionCookie("username", "password")
	if err != nil || res == false {
		fmt.Printf("Result: %v\n", res)
		panic(err)
	}

	issue, _, err := jiraClient.Issue.Get("SYS-5156")
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
}

Call a not implemented API endpoint

Lets get all public projects of Atlassian`s JIRA instance.

package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, _ := jira.NewClient(nil, "https://jira.atlassian.com/")
	req, _ := jiraClient.NewRequest("GET", "/rest/api/2/project", nil)

	projects := new([]jira.Project)
	_, err := jiraClient.Do(req, projects)
	if err != nil {
		panic(err)
	}

	for _, project := range *projects {
		fmt.Printf("%s: %s\n", project.Key, project.Name)
	}

	// ...
	// BAM: Bamboo
	// BAMJ: Bamboo JIRA Plugin
	// CLOV: Clover
	// CONF: Confluence
	// ...
}

Implementations

License

This project is released under the terms of the MIT license.