Page cover

๐ŸงฑVersions

Get project versions

GET /rest/api/{2-3}/project/{projectIdOrKey}/versions

Returns all versions in a project. The response is not paginated.

package main

import (
	"context"
	"fmt"
	_ "github.com/ctreminiom/go-atlassian/v2/jira/v3"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
	"os"
)

func main() {

	/*
		----------- Set an environment variable in git bash -----------
		export HOST="https://ctreminiom.atlassian.net/"
		export MAIL="MAIL_ADDRESS"
		export TOKEN="TOKEN_API"

		Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
	*/

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	versions, response, err := atlassian.Project.Version.Gets(context.Background(), "KP")
	if err != nil {
		if response != nil {
			log.Println("Response HTTP Response", response.Bytes.String())
		}
		log.Fatal(err)
	}

	log.Println("Response HTTP Code", response.Code)
	log.Println("HTTP Endpoint Used", response.Endpoint)

	for _, version := range versions {
		fmt.Println(version)
	}
}

Create version

POST /rest/api/{2-3}/version

Creates a project version.

Get version

GET /rest/api/{2-3}/version/{id}

Returns a project version.

Update version

PUT /rest/api/{2-3}/version/{id}

Updates a project version.

Merge versions

PUT /rest/api/{2-3}/version/{id}/mergeto/{moveIssuesTo}

Merges two project versions. The merge is completed by deleting the version specified in id and replacing any occurrences of its ID in fixVersion with the version ID specified in moveIssuesTo.

GET /rest/api/{2-3}/version/{id}/relatedIssueCounts

Returns the following counts for a version:

  • Number of issues where the fixVersion is set to the version.

  • Number of issues where the affectedVersion is set to the version.

  • Number of issues where a version custom field is set to the version.

Get version's unresolved issues count

GET /rest/api/{2-3}/version/{id}/unresolvedIssueCount

Returns counts of the issues and unresolved issues for the project version.

Last updated

Was this helpful?