Overview

Providing methods for accessing, creating, editing, searching JIRA issues out of Drupal using JIRAs REST API.

Features
- search
- create
- modify
- attach files to
- close
JIRA-issues

Drupal 7

Requirements
Make sure that you have curl installed in your system, for installation help visit:
http://www.php.net/curl

Setup

  • install the module
  • configure parameters of your jira site (e.g. URL) at:
    admin/config/services/jira_rest
  • start using jira_rest functions, see example below

Quick Example

Let's say you like to search issues which are not resolved/closed from a project with the key = PROJECTKEY

If you dont't want to use the default user defined during "Setup", set credentials in an options-array:
$options = array('username' => 'your_jira_user', 'password' => 'the_password');

$foundissues = jira_rest_issue_search("project=PROJECTKEY&status!=RESOLVED&status!=CLOSED", $options);

$foundissues contains now the issue objects found represented by an array. Looping over the issues, you can e.g. access fields of a single issue e.g. like this:

foreach ($foundissues as $issue){
  $issuekey = $issue->key;
  $description = $issue->fields->description
  $parentkey = $issue->fields->parent->key;
  $customfielddata = $issue->fields->customfield_10404;
}

Drupal 8

From 8.x-2.x on module will be based on jira-php-api library which uses guzzle instead of cURL.

From 8.x-3.x on module will require the Key module.
Using Key for the jira users password prevents that it could be read from config export.

Please use composer to download it into your D8 project, e.g. install current 8.x-3.x-dev by running the following command in the drupal root folder /where your composer.json resides:
composer require drupal/jira_rest:3.x-dev
or current stable release 8.x-3.1 with:
composer require drupal/jira_rest:3.1
Make sure you have the key module installed:
composer require drupal/key

Quick Start:
- enable the module by navigating to "Extend" (admin/modules) or via drush
- setup your JIRA instance & parameters under this route: admin/config/jira_rest/config
- try if you can reach the route /jira_rest/test from your admin account

Quick Examples
(load issue by key)

    $jira_rest_wrapper_service = new JiraRestWrapperService();
    $issue = $jira_rest_wrapper_service->getIssueService()->load('PROJECT-KEYID');

(search)

$search = $this->jiraRestWrapperService->getIssueService()->createSearch();

    // search for existing open issues
    $search->search(utf8_encode("status = Open"));

    foreach ($search->getIssues() as $i){
      $issue = $i;
      break;
    }

    $issuekey = $issue->key
    ...

(create issue and subissue)

    $issue = $this->jiraRestWrapperService->getIssueService()->create();
    //mandatory fields to set
    $issue->fields->project->setKey('DEV'); //or you can use the project id with: $issue->fields->project->setId($jiraProjectId);
    $issue->fields->setDescription(utf8_encode('title of issue') );
    $issue->fields->issuetype->setId('1');	// Issue type : Bug
    $issue->fields->addGenericJiraObject('priority');
    $issue->fields->priority->setId('4'); //Priority Minor
    $issue->fields->setSummary(utf8_encode('a summary / description'));
    //create the parent issue
    $issue->save();
    
    //set a label
    $labels[] = utf8_encode('Urgent');
    $issue->fields->setLabels($labels);
    //add a comment
    $issue->addComment('a comment to be added',true); //true for forcing presaving the issue object
    
    //creating a subissue
    
    $subissue = $issue->createSubIssue();
    $subissue->fields->project->setKey('DEV');
    $subissue->fields->setDescription(utf8_encode('a title for subissue') );
    $subissue->fields->issuetype->setId('8');	// Sub-task issuetype: Technical task
    $subissue->fields->addGenericJiraObject('priority');
    $subissue->fields->priority->setId('4');
    $subissue->fields->setSummary(utf8_encode('a desc for subissue'));

    $subissue->addComment('subissue added by xxx',true);
    $subissue->save();

Sponsors
bio.logis bio.logis Genetic Information Management GmbH.

Supporting organizations: 

Project information

Releases