分配了一个故事 (HierarchicalRequirement) 对象。使用Rally Ruby REST 工具包
下面的代码打印:
my_story: abc, FormattedID: US86, _ref:https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/12891971030
.
@rally = RallyAPI::RallyRestJson.new(config)
some_name = "abc"
query = RallyAPI::RallyQuery.new()
query.type = :story
query.fetch = "FormattedID"
query.query_string = "(Name = \"#{some_name}\")"
results = @rally.find(query)
my_story = results.first
puts "my_story: #{my_story}, FormattedID: #{my_story["FormattedID"]}, _ref:#{my_story["_ref"]}"
如果在您的代码中您尝试查找基于 FormattedID 的用户故事,这里有一个示例。它是否是父母并不重要,因为故事的父母就是故事,为了清楚起见,我在脚本中使用了“故事”而不是“父母”。在此示例中,将 FormattedID 作为命令行参数输入。注意我使用story = result.first
,而不是story=result
。这是输出的屏幕截图:
require 'rally_api'
#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "find story"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"
# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user@co.com"
config[:password] = "secret"
config[:workspace] = "X"
config[:project] = "Y"
config[:version] = "v2.0"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
unless ARGV.length == 1
puts "enter one argument, e.g. US123, with no spaces"
exit
end
story = nil
story_id = ARGV[0]
puts "find story by FormattedID: #{story_id}"
@rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :story
query.fetch = "Name,FormattedID,ScheduleState"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111.js" }
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222.js" }
query.project_scope_up = true
query.project_scope_down = true
query.query_string = "(FormattedID = \"#{story_id}\")"
result = @rally.find(query)
if(result.length > 0)
puts "found the story"
story = result.first
puts "FormattedID: #{story["FormattedID"]}, Name: #{story["Name"]}, ScheduleState: #{story["ScheduleState"]}"
else
puts "did not find a story with FormattedID #{story_id}"
end
puts story.class
puts story.inspect