Hooks & APIs

Bulk Change REST API

 

The bulk change API extends the possibility of importing and exporting repository configuration by automating the process via scripts.

To use the API, users must:

  • install the Requests Python package.
  • declare JIRA_BASE, JIRA_USER, and JIRA_PASSWORD in the configuration_conf.py file.  The JIRA_USER defined in this file must have JIRA Admin global permissions.(Download sample file as a zip file.)
helpful tip
HTTP Status code response:
  • 200  –  success
  • 401  –  user is unauthorized
  • 403  –  lack of privileges (The user doesn't have JIRA Admin global permission)
 
Bulk Export Configuration
url
/rest/gitplugin/1.0/configuration

The API returns a file with the plugin configuration.
method
GET
parameters
None
response
Generates a tab-separated values (.tsv) file.
Download sample file
  configuration_get.py

 

Example:
Usage:
user@home:~$ python configuration_get.py > conf.tsv
Bulk Import Configuration
url
/rest/gitplugin/1.0/configuration.json

Starts the process of importing configuration and returns the result at once.
method
POST
parameters
file
Input the path to the tab-separated values (.TSV) file.
confirmed-delete[ ]
Optional.  Accepts multiple repository IDs confirmed for deletion.  Input one or more repositories to delete, separated by commas.

Repositories won't be deleted if it's not in this list.
response
JSON          Returns the ID of the importing thread.
warning
The Git Add-on will ignore fields with blank entries.
Download sample file
  configuration_post.py
 
Example:
http://jira.example.org/rest/gitplugin/1.0/configuration.json

Response example:
{
  "success":false,
  "threadId":142
}

Usage:
Importing configuration from conf.tsv file:

user@home:~$ python configuration_post.py conf.tsv
{"success":false,"reposToDelete":[{"id":14,"description":"test-repo"},
{"id":15,"description":"test-repo"}]}

Importing configuration from conf.tsv file with confirm delete:

user@home:~$ python configuration_post.py conf.tsv 14,15
{"success":false,"threadId":1058}
Getting Bulk Import Information
url
/rest/gitplugin/1.0/configuration/progress.json

Obtains information about the importing thread.  Use the following path format to access bulk import information.
method
GET
parameters
thread_id
Required.  Input a thread ID to access information about the specific thread process.
response
JSON          Returns the status information of the import process.
Download sample file
  configuration_progress.py
 
Example:
http://jira.example.org/rest/gitplugin/1.0/configuration/progress.json?thread_id=123

Response example:
{
  "success":false,
  "finished":true,
  "progressEntries":[{
    "prcntDouble":0.0,
    "prcntInteger":0,
    "error":false,
    "message":"Creating repository git@github.com:user/test-repo.git"
   },{
    "error":true,
    "message": "java.lang.NullPointerException"
   },{
    "prcntDouble":100.0,
    "prcntInteger":1042,
    "error":false,
    "message":"Resolving deltas"
   }
  ]
}


Usage:
user@home:~$ python configuration_progress.py 1058
{"success":false,"finished":true,"progressEntries":[{
...