2

我正在为我试图让出到 csv 的一些 Rally 记录获取对象引用(功能)。有谁知道获取 PortfolioItem/Feature 数据记录的 Rally api 语法?

提前致谢。

这是我的 Python 代码片段。

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

这是打印字段的输出: ([], u'US136', None,

第一列是标签,所以如果那里有记录,我会得到一个对象。第四列返回“”。我需要从这个对象中获取数据。提取数据的最佳方法是什么?

谢谢

4

2 回答 2

0

如果您需要获得特定功能,可以尝试以下操作:

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()

如果您想从 Project 中获取所有功能,请使用以下方法:

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
于 2017-04-09T07:23:34.227 回答
0

试试这个代码示例:

#
# 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}'"
于 2017-03-27T00:57:46.313 回答