Forge command line/6.1
This page in other versions: master
FusionForge provides a php script forge located in ~/bin/ which supports general commands to perform such as plugins activation/deactivate and some import/export features.
This script has a basic internal help:
./forge help
Contents
Plugin Activation/Deactivation
It provides the capability to activate or deactivate forge-wide a plugin.
To activate:
./forge pluginActivate <name_of_the_plugin>
To deactivate:
./forge pluginDeactivate <name_of_the_plugin>
Import/Export functions
File Format
Import & export functions support 2 file formats:
- json (default)
- raw: this format is pure PHP Array.
The export functions echo information on stdout. To generate a file, redirect the stdout to a file.
Get binary data to an export element
By default, all export function does not retrive any binary data (documents, artifact attachments, etc.). To retrieve the binary data, use the getZipDump function. This function generates a zip with all binary data as described in the parameter file.
./forge getZipDump <parameter_file> [json|raw]
How to generate import files
The easiest way to generate import files is to use export functions, i.e: use userDump to generate the json file, then modify this file to reflect the needs and use it as import file.
User
To export an existing user:
./forge userDump <user_id> [json|raw]
To import an user:
./forge userImport <file> [json|raw]
Sample import json file:
{ "data_array": { "user_name": "admin", "email": "root@localhost.localdomain", "firstname": "Forge", "lastname": "Admin", "theme_id": "5", "password": "Inject123$", } }
The command line supports user by user import only. To import multiple users, create one file per user then loop on the files to call the forge userImport function.
Project
The forge command line supports import and export project.
To export a project:
./forge groupDump <group_id> [json|raw]
To import a project:
./forge groupImport <file> [json|raw]
The command line supports project by project import only. To import multiple projects, you need to loop on the groupImport function.
Document Management
The forge command line supports document, folder or the full document management import/export.
document export
To export a document:
./forge documentDump <document_id> [json|raw]
A document export includes:
- associated object ids by type and association direction (From/To)
- full description of the document called data_array. Values such as title, description, filetype, filename, filesize are based on the version
- internal error codes
- document id (information duplicated in the data_array as well)
- monitoring users
- all reviews
- all versions
Sample of export as json of a document:
{ "associatedFromArray": [ ], "associatedToArray": { "FRSRelease": { "2": [ "1" ] } }, "associationCounter": 1, "data_array": { "0": "testuser", "user_name": "testuser", "1": "Test USER", "realname": "Test USER", "2": "test.user@localhost.localdomain", "email": "test.user@localhost.localdomain", "3": "10", "group_id": "10", "4": "4", "docid": "4", "5": "1", "stateid": "1", "6": "my doc", "title": "my doc", "7": "0", "updatedate": "0", "8": "1488873819", "createdate": "1488873819", "9": "103", "created_by": "103", "10": "17", "doc_group": "17", "11": "my description", "description": "my description", "12": "0", "download": "0", "13": "http:\/\/google.fr", "filename": "http:\/\/google.fr", "14": "URL", "filetype": "URL", "15": "0", "filesize": "0", "16": "0", "reserved": "0", "17": null, "reserved_by": null, "18": "0", "locked": "0", "19": null, "locked_by": null, "20": "0", "lockdate": "0", "21": "active", "state_name": "active", "22": "TEST", "group_name": "TEST", "23": "1", "version": "1", "24": "11", "serial_id": "11" }, "error_code": 0, "error_message": null, "error_state": false, "id": "4", "monitor": [ ], "reviews": [ { "0": "8", "revid": "8", "1": "103", "created_by": "103", "2": "1", "statusid": "1", "3": "4", "docid": "4", "4": "1488873859", "startdate": "1488873859", "5": "1489622400", "enddate": "1489622400", "6": "a review", "title": "a review", "7": "a description", "description": "a description", "8": "11", "serialid": "11", "comments": [ ], "users": [ { "0": "8", "revid": "8", "1": "103", "userid": "103", "2": "1", "typeid": "1", "3": "1", "statusid": "1", "4": null, "updatedate": null, "5": "pending", "statusname": "pending" } ] } ], "versions": [ { "0": "11", "serial_id": "11", "1": "1", "version": "1", "2": "4", "docid": "4", "3": "1", "current_version": "1", "4": "my doc", "title": "my doc", "5": "0", "updatedate": "0", "6": "1488873819", "createdate": "1488873819", "7": "103", "created_by": "103", "8": "my description", "description": "my description", "9": "http:\/\/google.fr", "filename": "http:\/\/google.fr", "10": "URL", "filetype": "URL", "11": "0", "filesize": "0", "12": "my comment", "vcomment": "my comment", "storageref": null } ] }
document import
To import a document:
./forge documentImport <file> [json|raw]
directory export
To export a directory:
./forge docgroupDump <docgroup_id> [json|raw]
The directory export includes:
- full description of the directory (called data_array)
- internal error codes
- all documents (called files). See above for document dump description
- directory id
- subdocgroups (docgroup is the internal name of a directory) and the content of each subgroup. The export is recursive.
Example of a directory dump & retrieve the storage object into a ZIP file. In this example, the directory to dump has id 8. The dump is done in 2 steps.
- dump the json file
- use the json file as parameter to getZipDump function
./forge docgroupDump 8 > docgroupdump-8.json ./forge getZipDump docgroupdump-8.json
As result, user has in his working directory the following file:
- fusionforge-zipDump-<epoch>.zip
The content of this ZIP file is:
. ├── docman │ ├── 1 │ │ └── 0 │ └── 2 │ └── 0 └── parameter.json
Once unzip, this can be used as a starting point to be modified and be imported.
- parameter.json is the complete description of the docgroup dump
- docman directory includes binary related to documents.
directory import
To import a directory:
./forge docgroupImport <file> [json|raw]
document management export
To export the full document management:
./forge docmanDump <group_id> [json|raw]
document management import
To import the full document management:
./forge docmanImport <file> [json|raw]
Tracker
The forge command line supports artifact or tracker export/import.
To export an artifact:
./forge artifactDump <artifact_id> [json|raw]
Sample export as json file of an artifact:
{ "associatedFromArray": [ ], "associatedToArray": [ ], "associationCounter": 0, "children": null, "data_array": { "0": "22", "artifact_id": "22", "1": "104", "group_artifact_id": "104", "2": "1", "status_id": "1", "3": "1", "priority": "1", "4": "103", "submitted_by": "103", "5": "100", "assigned_to": "100", "6": "1496243461", "open_date": "1496243461", "7": "0", "close_date": "0", "8": "my new bug", "summary": "my new bug", "9": "the new bug:\r\n\r\n* markdown?", "details": "the new bug:\r\n\r\n* markdown?", "10": "None", "assigned_unixname": "None", "11": "Nobody", "assigned_realname": "Nobody", "12": "noreply@sourceforge.net", "assigned_email": "noreply@sourceforge.net", "13": "testuser", "submitted_unixname": "testuser", "14": "Test USER", "submitted_realname": "Test USER", "15": "test.user@localhost.localdomain", "submitted_email": "test.user@localhost.localdomain", "16": "Open", "status_name": "Open", "17": "1514916965", "last_modified_date": "1514916965", "18": "103", "last_modified_by": "103", "19": "testuser", "last_modified_unixname": "testuser", "20": "Test USER", "last_modified_realname": "Test USER", "21": "test.user@localhost.localdomain", "last_modified_email": "test.user@localhost.localdomain" }, "error_code": 0, "error_message": null, "error_state": false, "extra_field_data": { "106": { "name": "custom", "value": "None", "type": "1", "element_id": "100" }, "110": { "name": "My Text", "value": "", "type": "4" }, "108": { "name": "status", "value": "Open", "type": "7", "element_id": "20" }, "109": { "name": "Date de d\u00e9but", "value": "", "type": "12" }, "112": { "name": "Dependencies", "value": "", "type": "23" } }, "files": null, "history": [ { "id": "296", "artifact_id": "22", "field_name": "details", "old_value": "the new bug:\r\n*markdown?", "entrydate": "1514916943", "user_name": "testuser" }, { "id": "295", "artifact_id": "22", "field_name": "details", "old_value": "the new bug", "entrydate": "1514916928", "user_name": "testuser" } ], "messages": [ { "id": "113", "artifact_id": "22", "from_email": "test.user@localhost.localdomain", "body": "another comment:\r\n\r\n* markdown?", "adddate": "1514916965", "user_id": "103", "email": "test.user@localhost.localdomain", "user_name": "testuser", "realname": "Test USER" }, { "id": "112", "artifact_id": "22", "from_email": "test.user@localhost.localdomain", "body": "my specific comment:\r\n* markdown format\r\n", "adddate": "1514916453", "user_id": "103", "email": "test.user@localhost.localdomain", "user_name": "testuser", "realname": "Test USER" } ], "monitor": [ ], "parent": null, "related_tasks": null, "relatedtasks": [ ], "status_res": null, "votes": [ 0, 0, 0 ] }
To import an artifact:
./forge artifactImport <file> [json|raw]
To export a tracker:
./forge trackerDump <tracker_id> [json|raw]
To import a tracker:
./forge trackerImport <file> [json|raw]