Open main menu

Extension talk:Jira Ticket

Contents

PatchversionEdit

works fine. for others: The code must be (copy and paste 1:1)

<?php
/**
* Links a single Jira ticket with status and priority into an article.
*
* Author : David Seymore with RNSolutions
* Version : 2008-03-11
* License : GPLv2 
*
* Modified by Stephane GALLAND
* 2010-07-19 for janus-project.org usage.
*/ 
 
if( !defined( 'MEDIAWIKI' ) ) {
  echo(" This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
  die( -1 );
}
 
#SETUP - we need to know which thing we are looking at
$jiraHost='http://localhost';
$jiraUser='';
$jiraPass=''; 

 $wgExtensionCredits['other'][] = array(
        'name' => 'JiraTicket',
        'author' => array('David Seymore', 'Stephane Galland'),
        'url' => 'http://www.mediawiki.org/wiki/Extension:Jira_Ticket',
        'description' => 'Jira Status & Priority icon parser.',
        'description' => 'Jira Status & Priority icon parser, modifier to work on janus-project.org.',
 );
 
$wgExtensionFunctions[] = "wfSetupJiraTicket";
 
function wfSetupJiraTicket() {
   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', 'jiraTicket_render' );
 }
 
 
 # The callback function for converting the input text to HTML output
function jiraTicket_render( $input='', $argv='', $parser=null, $frame ) {
      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();

      # In case we are being called from within a template, we must first expand the parameter:
      $issueId = $parser->recursiveTagParse( $input, $frame );

      $jiraUrl = "$jiraHost/rpc/soap/jirasoapservice-v2?wsdl";

              try {
              $jiraSoap = new SoapClient($jiraUrl);
              $auth = $jiraSoap->login($jiraUser,$jiraPass);
              $issue = $jiraSoap->getIssue($auth,$issueId);
      }
      catch(Exception $e) {
              return "<!-- ".$e->getMessage().
                      " --><span title=\"".$e->getMessage()."\"><s>$issueId</s></span>";
      }
 
      $issuelabel = "$issueId";
        $output1 = '<a href="'.$jiraHost.'/browse/'.$issueId.'" alt="'.$issue->summary.'" title="'.$issue->summary.'">';
        $output2 = '</a>&nbsp;<img src="'.$jiraHost.'/images/icons/status_';
 
     #The status switch.. you may have reconfigured your custom statuses, so, edit here.. 
         switch($issue->status){
                 case 1:
                        $output2 .= 'open';
                         break;
                 case 3:
                        $output2 .= 'inprogress';
                         break;
                 case 4:  
                        $output2 .= 'reopened';
                         break;
                 case 5:  
                        $output2 .= 'resolved';
                      $issuelabel = "<s>$issuelabel</s>";
                         break;
                 case 6:
                        $output2 .= 'closed';
                      $issuelabel = "<s>$issuelabel</s>";
                         break;
                 default:
                        $output2 .= $issue->status;
                         break;
         }
        $output2 .= '.gif">';
 
     #The priority switch... you may have reconfigured your custom priorities, so, edit here...
        $output2 .= '<img src="'.$jiraHost.'/images/icons/priority_';
         switch($issue->priority){
                 case 1:
                        $output2 .= 'blocker';
                         break;
                 case 2:  
                        $output2 .= 'critical';
                         break;
                 case 3:
                        $output2 .= 'major';
                         break;
                 case 4:
                        $output2 .= 'minor';
                         break;
                 case 5:
                        $output2 .= 'trivial';
                         break;
                 default:
                        $output2 .= $issue->priority;
                         break;
         }
        $output2 .= '.gif">';
 
 
  return "$output1$issuelabel$output2";
 }
 
?>

— Preceding unsigned comment added by 217.91.185.104 (talkcontribs) 14:57, 4 April 2011‎

Above updated by Christian Ettinger (talk · contribs) 06:43, 3 May 2011

No longer works for Version 1.20Edit

Is this extension being maintained?

Where are the icons?Edit

This extension (the version on this Talk page) is working fine with MW 1.23. For those of you still using it, is there a set of icons available online, or did you all make your own?

Thanks. --Salquint (talk) 15:23, 19 March 2015 (UTC)


It appears to use the icons from Jira itself (i.e. cross-links the image from the jira server):

<img src="'.$jiraHost.'/images/icons/status_';
    #The status switch.. you may have reconfigured your custom statuses, so, edit here.. 
         switch($issue->status){
                 case 1:
                        $output2 .= 'open';
                         break;
[...snip...]
         }
        $output2 .= '.gif">';

Assuming you have $jiraHost configured properly at the top of the file, this should result in something like: http://jira.yourDomain.tld/images/icons/status_open.gif. You should be able to directly hit that URL and see the resulting image. --173.11.59.193 17:28, 1 June 2015 (UTC)

Return to "Jira Ticket" page.