2

I'm getting object references(Feature) for some of the Rally records I'm trying to yield out to a csv. Does anyone know the Rally api syntax to get to the record of the PortfolioItem/Feature data?

Thanks in advance.

Here is my Python code snippet.

def getUserStories():
    response = rally.get("HierarchicalRequirement",fetch=True, pagesize=200, limit=50)
    for item in response:
        FIELDS = (item.FormattedID, item.Feature, item.Description,
                  item.Name, item.Notes, item.Parent)
        yield FIELDS

This is the output from a print FIELDS: ([], u'US136', None,

The first column is Tags so if there is a record there, I get an object. The fourth column returns "". I need to get the data from this object. What is the best way to extract the data?

Thanks

shpfrmr
  • 21
  • 3

2 Answers2

0

Try this code sample:

#
# Usage: ruby get_story_feature_short.rb <Story-FormattedID>
#

require './MyVars.rb' # Credential variables stored here
require 'rally_api'
headers = RallyAPI::CustomHttpHeader.new({:vendor=>"JP",:version=>"3.14"})
@rallycon = RallyAPI::RallyRestJson.new({
           :base_url     => $my_base_url,
           :username     => $my_username,
           :password     => $my_password,
           :workspace    => $my_workspace,
           :project      => $my_project,
           :version      => "v2.0",
           :headers      => headers})
qstring = {:type         => :story,
           :query_string => "(FormattedID = \"#{ARGV[0]}\")",
           :fetch        => 'true'}
stories = @rallycon.find(RallyAPI::RallyQuery.new(qstring))
my_us = stories.first # Take the first one (even though there is only one)
feature = my_us.Feature.read # Read the Feature
puts "User-story '#{ARGV[0]}' is part of Feature '#{feature.FormattedID}'"
JPKole
  • 341
  • 1
  • 6
  • I'm not familiar with Ruby but I tried the code above after changing my myvars.rb data but no joy. I'm wanting to get my export working using pyral since i'm more familiar with Python. – shpfrmr Mar 29 '17 at 16:18
0

If you need to get a particular Feature you can try this:

from pyral import Rally

SERVER = 'SERVER'
USER = 'USER'
PASSWORD = 'PASSWORD'
WORKSPACE = 'WORKSPACE'
PROJECT = 'PROJECT'
TARGET = 'FEATURE_ID'

if __name__ == '__main__':
    rally = Rally(SERVER, USER, PASSWORD, workspace=WORKSPACE, project=PROJECT)

    feature_req = rally.get('Feature', fetch=True, query='FormattedID = %s' % (TARGET))
    feature = feature_req.next()
    #do all required operations with fields
    print feature.details()

If you want to get all Features from Project then the following approach:

from pyral import Rally

SERVER = 'SERVER'
USER = 'USER'
PASSWORD = 'PASSWORD'
WORKSPACE = 'WORKSPACE'
PROJECT = 'PROJECT'

if __name__ == '__main__':
    rally = Rally(SERVER, USER, PASSWORD, workspace=WORKSPACE, project=PROJECT)

    features = rally.get('Feature', fetch=True, pagesize=200)
    for feature in features:
        #do all required operations with fields
        pass
user2738882
  • 1,161
  • 1
  • 20
  • 38