jiralib4r

Some additional helpful functions for jira4r

Name jiralib4r
Version 1.0
Author(s) Charles Miller
Home Page http://www.atlassian.com/
Download Location jiralib.rb

Description/Features

Helper methods to script things I don't like having to do manually in JIRA. Requires (and adds methods to) jira4r. Only does a simple form of bulk edit for now, but I expect it will grow as I find more things I want to automate.

The Code

require 'jira4r'

# JIRAlib - some useful functions for JIRA
# Adds these methods to the JIRA::Server class
module JIRA
   class Server
      # Load a list of issue keys from a file into an
      # array. Assumes the keys are one per line in
      # the file. 
      # 
      # If you supply a project_key parameter, then it's
      # assumed that all the lines are numeric, and the
      # project key will be prepended to make them an
      # issue-key.
      def load_keys(filename, project_key = nil)
         keys = IO.readlines(filename).map do |key|
            key.chomp!
            project_key ? "#{project_key}-#{key}" : key
         end
      end
      
      # Update a series of issues to have particular attributes.
      # Takes an array of issue keys, and the attributes you want
      # to set on those issue.
      #
      # Also takes an optional block that is called after the update
      # on each issue, in case you want to print out statuses or something
      #
      # e.g. to set a number of issues to have no fix-for version:
      #
      # keys = ["TST-1", "TST-2", "TST-3"]
      # jira.bulk_set_attributes(keys, {"fixVersions" => []}) do |key, issue|
      #    puts "Postponed issue: #{key} - #{issue['summary']}"
      # end
      def bulk_set_attributes(keys, attributes)
         keys.each do |key| 
            issue = self.updateIssue(key, attributes)
            yield(key, issue) if block_given?
         end
      end
   end
end
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.