How to bulk release versions through REST API in Jira
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article covers a way, through REST API calls, to bulk release versions in Jira.
The solution presented here can be tweaked to update any info on versions too.
The User Interface (UI) doesn't provide a bulk edition feature, only making it possible to update versions on a one-by-one basis:
A built-in bulk edit feature's being tracked on JRASERVER-10981 - Bulk Version Management.
Environment
All versions of Jira Core and Software from 7.x to 8.x.
Solution
Through the REST API, we'll print the commands to update each unreleased version for the same project. The output commands will be ready to be executed back in the terminal.
This solution may be adjusted to bulk update other fields available on the update Version endpoint:
{
"self": "http://www.example.com/jira/rest/api/2/version/10000",
"id": "10000",
"description": "An excellent version",
"name": "New Version 1",
"archived": false,
"released": true,
"releaseDate": "2010-07-06",
"overdue": true,
"userReleaseDate": "6/Jul/2010",
"projectId": 10000
}
1) Produce the update commands
Execute the below command to list the update commands for all unreleased versions from project P1.
On the examples below, replace http://localhost:50805
by your Jira's base URL (port optional), admin:admin
by an admin's username:password
and P1
by the project key which versions are to be updated:
curl -s -u admin:admin -H "Content-Type: application/json" -X GET "http://localhost:50805/rest/api/2/project/P1/versions" | egrep -o '{.*?}' | grep '"released":false' | sed 's/{"self"://g' | awk -F"," '{print "curl -s -k -u admin:admin -H \"Content-Type: application/json\" -X PUT --data '\''{"$3", \"released\":\"true\", \"releaseDate\":\"2020-11-02\"}\'\'' " $1}'
curl -s -u admin:admin -H "Content-Type: application/json" -X GET "http://localhost:50805/rest/api/2/project/P1/versions" | egrep -o '{.*?}' | grep '"released":false' | sed 's/{"self"://g' | awk -F"," '{print "curl -s -k -u admin:admin -H \"Content-Type: application/json\" -X PUT --data '\''{"$3", \"released\":\"true\", \"releaseDate\":null}\'\'' " $1}'
The output should be similar to:
curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT --data '{"name":"v1", "released":"true", "releaseDate":"2020-11-02"}' "http://localhost:50805/rest/api/2/version/10100"
curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT --data '{"name":"v2", "released":"true", "releaseDate":"2020-11-02"}' "http://localhost:50805/rest/api/2/version/10101"
curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT --data '{"name":"v3", "released":"true", "releaseDate":"2020-11-02"}' "http://localhost:50805/rest/api/2/version/10102"
curl -s -k -u admin:admin -H "Content-Type: application/json" -X PUT --data '{"name":"v4", "released":"true", "releaseDate":"2020-11-02"}' "http://localhost:50805/rest/api/2/version/10300"
You may copy the output to file and adjust the releaseDates accordingly for each version. Note the version "name" is being updated to the same value — it's just to make the editing of the output more human-friendly as you'll know to which version each line corresponds.
2) Execute the batch commands
Once you're satisfied with which versions will be updated and with which releaseDates
, simply copy the contents to the terminal. Each newline will be automatically executed.