1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-28 08:39:03 +02:00
Go to file
Andy Grunwald 72d53e4630 style: Adjust source code according gofmt -d -s
Adjusting source code according to the go coding guidelines
and simplify it a bit.
2020-04-29 10:27:02 -07:00
examples executable searchpages example 2018-11-18 10:46:16 +01:00
img little bigger 2018-04-28 21:32:27 +10:00
mocks feat: Implement get remote links method 2019-12-14 08:27:17 -08:00
.gitignore Add dep as a dependency manager 2018-02-17 11:14:47 -08:00
.travis.yml add go 1.13 builds, allowing failures 2019-09-05 11:03:44 -07:00
authentication_test.go go fmt and fixed some typos 2017-05-01 14:59:27 +02:00
authentication.go Cleaning a bunch of go vet issues 2018-02-28 22:46:54 -08:00
board_test.go feat: AddGetBoardConfiguration 2019-08-19 13:05:52 -07:00
board.go feat: AddGetBoardConfiguration 2019-08-19 13:05:52 -07:00
CHANGELOG.md chore(release): 1.11.1 2019-10-16 20:20:03 -07:00
component_test.go Add ComponentService to allow creation of Components 2018-06-25 10:48:21 -04:00
component.go Handle error with NewJiraError 2018-06-29 10:01:28 -04:00
error_test.go style: Adjust source code according gofmt -d -s 2020-04-29 10:27:02 -07:00
error.go style: Adjust source code according gofmt -d -s 2020-04-29 10:27:02 -07:00
field_test.go doc: Fix comments 2018-06-25 17:52:57 +02:00
field.go doc: Fix comments 2018-06-25 17:52:57 +02:00
filter_test.go fix: Fix typos in filter_test.go 2019-08-26 18:53:33 -07:00
filter.go feat: Add Search to FilterService 2019-08-26 18:53:33 -07:00
go.mod feat: add support for JWT auth with qsh needed by add-ons 2019-09-05 11:04:10 -07:00
go.sum feat: Add IssueLinkTypeService with GetList and test 2019-12-12 14:57:35 -08:00
group_test.go move agile issue api to sprint, change name of GetByOption to GetWithOptions 2018-04-03 14:29:29 +09:00
group.go feat: Add AccountID and AccountType to GroupMember struct 2019-07-12 20:44:42 -07:00
issue_test.go style: Adjust source code according gofmt -d -s 2020-04-29 10:27:02 -07:00
issue.go fix: change millisecond time format 2020-04-14 20:55:02 +02:00
issuelinktype_test.go feat: Implement issue link type DELETE 2019-12-12 14:57:35 -08:00
issuelinktype.go feat: Implement issue link type DELETE 2019-12-12 14:57:35 -08:00
jira_test.go feat: add support for JWT auth with qsh needed by add-ons 2019-09-05 11:04:10 -07:00
jira.go feat: Add IssueLinkTypeService with GetList and test 2019-12-12 14:57:35 -08:00
LICENSE Initial commit 2015-08-20 17:02:46 +02:00
Makefile Added Makefile 2017-02-28 10:02:05 +01:00
metaissue_test.go Added a GetCreateMetaWithOptions function, which extends the capabilities of GetCreateMeta to allow for options 2018-03-01 10:46:22 -05:00
metaissue.go Fix GetQueryOptions in issue.go to use projectKeys instead of projectKey 2018-03-05 08:56:57 -05:00
permissionscheme.go Add missing check to permissionSchemeService.Get 2019-05-13 18:33:41 -07:00
permissionschemes_test.go Add negative tests for PermissionService 2019-05-13 18:33:41 -07:00
priority_test.go test: Add unit test for priority api 2018-06-12 10:38:13 +02:00
priority.go test: Add unit test for priority api 2018-06-12 10:38:13 +02:00
project_test.go Add test case to check for completeness of roles unmarshal 2019-05-16 08:10:18 -07:00
project.go Fix of Project.Roles Unmarshal Bug 2019-05-16 08:10:18 -07:00
PULL_REQUEST_TEMPLATE.md Update PULL_REQUEST_TEMPLATE.md 2019-11-04 18:46:00 -08:00
README.md docs: Link to standard-version 2020-01-24 08:33:30 -08:00
resolution_test.go feat: Add ResolutionService to retrieve resolutions 2018-06-25 17:48:53 +02:00
resolution.go feat: Add ResolutionService to retrieve resolutions 2018-06-25 17:48:53 +02:00
role_test.go Add negative tests for RoleService 2019-05-13 17:55:06 -07:00
role.go Add missing check to roleService.Get 2019-05-13 17:55:06 -07:00
sprint_test.go move agile issue api to sprint, change name of GetByOption to GetWithOptions 2018-04-03 14:29:29 +09:00
sprint.go doc: Fix minor lint issues 2018-06-08 18:00:22 +02:00
status_test.go feat: Add GetAllStatuses 2019-08-19 07:51:49 -07:00
status.go feat: Add GetAllStatuses 2019-08-19 07:51:49 -07:00
statuscategory_test.go feat: Add StatusCategory GetList 2018-06-26 09:41:46 +02:00
statuscategory.go feat: Add StatusCategory GetList 2018-06-26 09:41:46 +02:00
user_test.go fix(IssueService.GetWatchers): UserService.GetByAccountID support accountId params 2020-03-11 12:57:09 -07:00
user.go fix(IssueService.GetWatchers): UserService.GetByAccountID support accountId params 2020-03-11 12:57:09 -07:00
version_test.go Manage versions startDate 2018-10-30 19:34:37 +01:00
version.go fix version struct description tags error 2019-12-07 15:47:34 -08:00

go-jira

GoDoc Build Status Go Report Card

Go client library for Atlassian JIRA.

Go client library for Atlassian JIRA

Features

  • Authentication (HTTP Basic, OAuth, Session Cookie)
  • Create and retrieve issues
  • Create and retrieve issue transitions (status updates)
  • Call every API endpoint of the JIRA, even if it is not directly implemented in this library

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 of JIRA have a look at latest JIRA REST API documentation.

Requirements

  • Go >= 1.8
  • JIRA v6.3.4 & v7.1.2.

Installation

It is go gettable

go get github.com/andygrunwald/go-jira

For stable versions you can use one of our tags with gopkg.in. E.g.

package main

import (
	jira "gopkg.in/andygrunwald/go-jira.v1"
)
...

(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", nil)

	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
}

Authentication

The go-jira library does not handle most authentication directly. Instead, authentication should be handled within an http.Client. That client can then be passed into the NewClient function when creating a jira client.

For convenience, capability for basic and cookie-based authentication is included in the main library.

Basic auth example

A more thorough, runnable example is provided in the examples directory. It's worth noting that using passwords in basic auth is now deprecated and will be removed. Jira gives you the ability to create tokens now.

func main() {
	tp := jira.BasicAuthTransport{
		Username: "username",
		Password: "token",
	}

	client, err := jira.NewClient(tp.Client(), "https://my.jira.com")

	u, _, err := client.User.Get("some_user")

	fmt.Printf("\nEmail: %v\nSuccess!\n", u.EmailAddress)
}

JIRA deprecated this authentication method. It's not longer available for use.

Authenticate with OAuth

If you want to connect via OAuth to your JIRA Cloud instance checkout the example of using OAuth authentication with JIRA in Go by @Lupus.

For more details have a look at the issue #56.

Create an issue

Example how to create an issue.

package main

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

func main() {
	base := "https://my.jira.com"
	tp := jira.BasicAuthTransport{
		Username: "username",
		Password: "token",
	}

	jiraClient, err := jira.NewClient(tp.Client(), base)
	if err != nil {
		panic(err)
	}

	i := jira.Issue{
		Fields: &jira.IssueFields{
			Assignee: &jira.User{
				Name: "myuser",
			},
			Reporter: &jira.User{
				Name: "youruser",
			},
			Description: "Test Issue",
			Type: jira.IssueType{
				Name: "Bug",
			},
			Project: jira.Project{
				Key: "PROJ1",
			},
			Summary: "Just a demo issue",
		},
	}
	issue, _, err := jiraClient.Issue.Create(&i)
	if err != nil {
		panic(err)
	}

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

Call a not implemented API endpoint

Not all API endpoints of the JIRA API are implemented into go-jira. But you can call them anyway: Lets get all public projects of Atlassian`s JIRA instance.

package main

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

func main() {
	base := "https://my.jira.com"
	tp := jira.BasicAuthTransport{
		Username: "username",
		Password: "token",
	}

	jiraClient, err := jira.NewClient(tp.Client(), base)
	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

Code structure

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

There is one main part (the client). Based on this main client the other endpoints, like Issues or Authentication are extracted in services. E.g. IssueService or AuthenticationService. These services own a responsibility of the single endpoints / usecases of JIRA.

Contribution

We ❤️ PR's

Contribution, in any kind of way, is highly welcome! It doesn't matter if you are not able to write code. Creating issues or holding talks and help other people to use go-jira is contribution, too! A few examples:

  • Correct typos in the README / documentation
  • Reporting bugs
  • Implement a new feature or endpoint
  • Sharing the love of go-jira and help people to get use to it

If you are new to pull requests, checkout Collaborating on projects using issues and pull requests / Creating a pull request.

Dependency management

go-jira uses go modules for dependency management. After cloning the repo, it's easy to make sure you have the correct dependencies by running go mod tidy.

For adding new dependencies, updating dependencies, and other operations, the Daily workflow is a good place to start.

Sandbox environment for testing

Jira offers sandbox test environments at http://go.atlassian.com/cloud-dev.

You can read more about them at https://developer.atlassian.com/blog/2016/04/cloud-ecosystem-dev-env/.

Releasing

Install standard-version

npm i -g standard-version
standard-version
git push --tags

Manually copy/paste text from changelog (for this new version) into the release on Github.com. E.g.

https://github.com/andygrunwald/go-jira/releases/edit/v1.11.0

License

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