How to automate export and load of complete projects




This section explains how to drive Project Configurator from the command line, so that you can create scripts that export or load complete projects. The method is based on interacting with the JIRA server by issuing http requests to concrete URLs. You need a tool that lets you issue http requests from the command line, as wget or curl. If you are not familiar with wget or curl, it is recommended you have a look first at the manual for these products.

Some examples are provided. Remember that the export and load operations require a user with system administrator permission.

These examples have been tested on Ubuntu Linux 16.04 and they use curl and xmllintBoth programs must be installed on the system where you are going to run the scripts, you can install them with the following commands:

    apt get update

    apt get install curl

    apt get install libxml2-utils

In order to execute the scripts provided, copy them to a folder included in your machine's path for executable files and make them executable.


Auxiliary scripts

The export and import scripts will need the following scripts to work:


Export script

This is an executable script that exports complete projects. 

Command and options

It is launched with the following command:

  • jira-host-url: Host part of the exporting instance base URL, including port if needed (for example http://my-server:2990).
  • jira-context-path: Context part of the exporting instance base URL (for example "jira").  Note that jira-host-url + "/" + jira-context-path equals "JIRA base URL" (for example, http://my-server:2990/jira)
  • admin-user: Admin's username.
  • admin-password: Admin's password.
  • export-file-name: Name of the exported file, remember it will be left in "projectconfigurator" folder under directory $JIRA_HOME/export (for example 'exported-projects-10-04-2017-zip').
  • project-key [project-key2 ...]: Keys of the projects to export, at least one must be provided.
  • export-options: Additional export options, see this link for details. Each export option must be specified as key=value, preferrably enclosed in double quotes.


Import script

This is an executable script that imports complete projects. 

Command and options

It is launched with the following command:


  • jira-host-url: Host part of the importing instance base URL, including port if needed.

  • jira-context-path: Context part of the importing instance base URL.
  • admin-user: Admin's username.
  • admin-password: Admin's password.
  • import-file-name: name of the file to be imported, remember it must be placed before importing in "projectconfigurator" folder under directory $JIRA_HOME/import.
  • import-options: additional import options, see this link for details. Each import option must be specified as key=value, preferrably enclosed in double quotes.

Temporary files and error handling


Examples

Export example

We're exporting the projects LOREM and IPSUM from the JIRA server located in 10.0.2.2:2990 into a file called scriptfile.zip, using the account admin:admin.


Import example

We're importing the projects LOREM and IPSUM from a file called scriptfile.zip into the server located in 10.0.2.2:2990, using the account admin:admin.

Error handling

Let's see a couple examples of error traces, and how to fix those errors.

As we can see, the trace ended with an http status: 500, and it says that we should check response.html.

Inside response.html, we can find:

As we can see, something in Project Configurator failed. After searching in PCP's wiki or contacting support, we find that this error happens because we tried to export a project with agile boards from a JIRA instance with JIRA Agile v6.7.6, and Project Configurator is only compatible with JIRA Agile v6.7.7 or higher.


This trace ended with an http status: 400, again, we check response.html to see what happened.

In response.html, we find:

Which means the filename was wrong, it doesn't exist or it may be missing its extension.