Extension:Jira Ticket
From MediaWiki.org
|
Release status: beta |
|
|---|---|
| Implementation | Parser extension, Tag |
| Description | Links a single Jira ticket with status and priority into an article |
| Author(s) | David Seymore with RNSolutions (DavidSeymoreTalk) |
| Last Version | 2008-03-11 (2008-03-11) |
| MediaWiki | tested on 1.11.1 |
| License | GPLv2 |
| Download | see below |
|
check usage (experimental) |
|
Like the Jira Extension, Jira Ticket extension allows you to link a MediaWiki instance with Jira. This extension allows a single ticket to be incorporated into an article by its ticket number. The ticket's status, priority, and number are displayed to the user as a URL to the ticket in Jira, and with the title of the ticket as the alternate text.
[edit] Installation
- Your PHP install will need to have Soap enabled.
- In your LocalSettings.php add:
require_once('extensions/jiraticket.php');
- Touch a file in the extensions directory named jiraticket.php
- Edit the file and place the following in it:
- Remember to edit the variables for jiraHost (root URL), jiraUser, jiraPrass
<?php // Make sure we are being called properly if( !defined( 'MEDIAWIKI' ) ) { echo(" This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( -1 ); } $wgExtensionCredits['other'][] = array( 'name' => 'jira', 'author' => 'David Seymore', 'url' => 'http://www.mediawiki.org/wiki/Extension:Jira_Ticket', 'description' => 'Jira Status & Priority icon parser.', ); $wgExtensionFunctions[] = "wfJira"; #SETUP - we need to know which thing we are looking at $jiraHost='http://your.jira.hostname.org'; $jira = array( 'user' => 'XXXXXXXXXX', 'password' => 'XXXXXX', 'url' => 'http://your.jira.hostname.org/rpc/soap/jirasoapservice-v2?wsdl' ); function wfJira() { global $wgParser; # register the extension with the WikiText parser # the first parameter is the name of the new tag. # In this case it defines the tag <jira>GS-1</jira> # the second parameter is the callback function for # processing the text between the tags $wgParser->setHook( "jira", "renderTick" ); } # The callback function for converting the input text to HTML output function renderTick( $input, $argv, &$parser ) { global $jiraHost, $jiraUser, $jiraPass; # You can disable the cache, but, rememeber that this'll hit jira everytime the page is read.. not exactly that smart # resaving an article will automatically pull down the fresh status of the jira ticket. # $parser->disableCache(); $jiraSoap = new SoapClient($jira['url']); $auth = $jiraSoap->login($jira['user'],$jira['password']); $issue = $jiraSoap->getIssue($auth,$input); $output = '<a href="'.$jiraHost.'/browse/'.$input.'" alt="'.$issue->summary.'" title="'.$issue->summary.'">'.$input.'</a> '; $output .= '<img src="'.$jiraHost.'/images/icons/status_'; #The status switch.. you may have reconfigured your custom statuses, so, edit here.. switch($issue->status){ case 1: $output .= 'open'; break; case 3: $output .= 'inprogress'; break; case 4: $output .= 'reopened'; break; case 5: $output .= 'resolved'; break; case 6: $output .= 'closed'; break; default: $output .= $issue->priority; break; } $output .= '.gif">'; #The priority switch... you may have reconfigured your custom priorities, so, edit here... $output .= '<img src="'.$jiraHost.'/images/icons/priority_'; switch($issue->priority){ case 1: $output .= 'blocker'; break; case 2: $output .= 'critical'; break; case 3: $output .= 'major'; break; case 4: $output .= 'minor'; break; case 5: $output .= 'trivial'; break; default: $output .= $issue->priority; break; } $output .= '.gif">'; return $output; }
[edit] Usage
- Simply take the jira ticket you want to use, and enclose it in the jira tag.
<jira>GS-763</jira>
- You'll end up with:
[edit] What's Next?
Parsing the data over HTTP is fine and dandy if you have a decent servers to handle it, but, using SOAP would make this extension MUCH faster. Expect that to come shortly.
- Since 03/11/2008 it uses SOAP/RPC to make the calls, and it is about 20x faster.